Skip to content

Unable to POST data in axios #1195

@awais-ilyas

Description

@awais-ilyas

I am using this code to POST the data to Web API
var param = {
args: {
myStringVal: '979251e4-6c9f-460d-ba32-1b6fe58ce8a3'
}
};

axios({
method: 'post',
url: 'api/Application/Action/MyWebAPIMethod',
data: JSON.stringify(param),
});

and my Web API code is like this:
public class MyClassVM
{
public string myStringVal { get; set; }
}
public MessageVM MyWebAPIMethod(MyClassVM args){
// my code goes here
}

Issue is: When I pass the myStringVal: '979251e4-6c9f-460d-ba32-1b6fe58ce8a3' it gives me null in Web API [args.myStringVal = null ].

How can I pass the values in axios POST.

Thanks in advance

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions