danwrong / restler

REST client library for node.js
MIT License
1.99k stars 391 forks source link

PATCH body? #191

Closed techguydave closed 9 years ago

techguydave commented 9 years ago

Does the PATCH method not include a way to send the body like POST and PUT?

techguydave commented 9 years ago

Nevermind. Didn't realize I had to set the header to application/json.

rain1024 commented 9 years ago

Hi synth3tk, how can you do it?

My code is not working

var headers = {
  "Authorization": "token " + accessToken,
  "Content-Type" : "application/json"
};

var id = "12345678";

var updatedData = {
  description: 'update doc',
  public: true,
  files: {
    'updated.md': { content: 'updated' } 
  }
}

rest
  .patch(
    "https://api.github.com/gists/" + id,
    {
      data: JSON.stringify(updatedData)
    },
    {
      headers: headers,
    })
    .on('complete', function(result){
      console.log(result);
    })

Use node-debugger, I found that rest object's headers doesn't contains Content-Type property

headers: Object
Accept: "*/*"
Accept-Encoding: "gzip, deflate"
Content-Length: 75
Host: "api.github.com"
User-Agent: "Restler for node.js"