Gerard Anthony McBride Gerard Anthony McBride - 5 months ago 54
Javascript Question

PUT/POST request sending without data

I have a client which makes the following request to a Pyramid Service.

var sendArr = {"hello": "world"};
type: "PUT",
contentType: "application/json",
url: "" + + newUrlSegment,
data: sendArr,
headers: { 'X-User-Email': loggedUser.user, "X-Auth-Token": loggedUser.token},
success: function(data,status,other){
console.log("server return", data);
error: function (XMLHttpRequest, textStatus, errorThrown){

The request is received by the server, however the request 'data' is missing.

Is there any particular reason why the data is not being attached client-side?

Answer Source

If you use:

data: JSON.stringify(sendArr)

It should work.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download