I have question about sending string value on axios post. I will provide code below for better understanding.
API CALL C# MVC .netcore
public async Task<IActionResult> Save(string Code, [FromBody]string notes)
{
------
}
so above it will get the data of string from FROMBODY
REACT FRONT END USING AXIOS CALL
export const sendNote = async (Url, code, value) => {
let Config = {
headers: {
"Content-Type": "application/json",
},
};
try {
const { data } = await axios.post(
Url + code + "/Notes",
value,
Config
);
return { data: data };
} catch (error) {
return { data: error.message };
}
};
So as you can see on the code above, I am trying to send the value which is a string to the api call on C# but I get many different error like 400 or 415. I researched it on google and they mostly put it on the json format.
So end it like "TEST" instead of {data: "TEST"}
Thank you
Content-Type: application/jsonThis should be more likeContent-Type: application/text.Content-Type: application/jsonand send a request body similar to this one{ notes: value }And also inspect with the web developer tools what data exactly you are sending