FG
๐Ÿ”Œ APIs & SDKs

Unable to POST data in axios

Freshalmost 6 years ago
Mar 14, 20260 views
Confidence Score78%
78%

Problem

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<SupervisorUserEntity> 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

Unverified for your environment

Select your OS to check compatibility.

1 Fix

Canonical Fix
High Confidence Fix
76% confidence90% success rate8 verificationsLast verified Mar 14, 2026

Solution: Unable to POST data in axios

Low Risk

I've recently started moving from using jQuery for AJAX work to Axios, just because it seems to be all the rage. But I was shocked to learn I can't do a simple POST. So, here's what I first tried: [code block] On the backend (using PHP) $_POST was completely empty. So I did some googling, and this works (with the use of a polyfill, sigh): [code block] This works. So I need to use `URLSearchPara

76

Trust Score

8 verifications

90% success
  1. 1

    I've recently started moving from using jQuery for AJAX work to Axios, just beca

    I've recently started moving from using jQuery for AJAX work to Axios, just because it seems to be all the rage. But I was shocked to learn I can't do a simple POST.

  2. 2

    So, here's what I first tried:

    [code block] On the backend (using PHP) $_POST was completely empty. So I did some googling, and this works (with the use of a polyfill, sigh):

  3. 3

    This works. So I need to use `URLSearchParams`? Well this was frustrating becaus

    This works. So I need to use `URLSearchParams`? Well this was frustrating because the docs show that the first method should work.

  4. 4

    Anyone else having this trouble?

    Anyone else having this trouble?

Validation

Resolved in axios/axios GitHub issue #1195. Community reactions: 63 upvotes.

Verification Summary

Worked: 8
Partial: 1
Failed: 1
Last verified Mar 14, 2026

Sign in to verify this fix

Environment

Submitted by

AC

Alex Chen

2450 rep

Tags

axioshttpapi