Search code examples
javascriptajaxrestpyramid

PUT/POST request sending without data


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

var sendArr = {"hello": "world"};
$.ajax({
    type: "PUT",
    contentType: "application/json",
    url: "http://0.0.0.0:6543/" + obj.id + 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){
        console.log(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?


Solution

  • If you use:

    data: JSON.stringify(sendArr)
    

    It should work.