I'm trying to use /registerDevice as an API on my nodejs server instead of having Apps do this... However, I keep getting 400 Bad Request data - and it doesn't tell me what part of data is bad...

here's my code: var options = { method: 'POST', url: 'https://cp.pushwoosh.com/json/1.3/registerDevice', json: true, body: { "application":config.pushwoosh.appcode, "push_token":my.mydeviceToken , //generated using Apple APN "language":"en", // optional "hwid": my.myDeviceId, //generated using app and APN "timezone": 3600, // offset in seconds "device_type":1 } }; request(options, function (error, response, body) { console.log(error, response); // I keep getting response as 400 - Bad Request Data - what part is bad here? });

asked 21 Aug '15, 16:35
jatinpatel's gravatar image


problem was that the payload needs to be inside "request" object...it's fixed now.

permanent link
answered 24 Aug '15, 17:42
jatinpatel's gravatar image


Hello! Could you possibly remove all the comments from the code and make sure the syntax is correct (i.e. the app code and push token should be in quotes)?

And the most important question — why would you need to register devices from your server? What values do you use in push token field?

permanent link
answered 24 Aug '15, 09:39
Benedict's gravatar image


var options = { method: 'POST', url: 'https://cp.pushwoosh.com/json/1.3/registerDevice', json: true, body: { "application":"1234-5678", "push_token":"56edcd52bc03a686ee024ffa40779b9c5ae56cd6dbd883310f2cfcf6803427ee", "hwid": "BA634921-99CC-4BDC-90F0-E5179F2B60F5", "device_type":"1" } }; Please see - I have everything in quotes. The reason to this from the server is everything from the apps goes through our server. When app is first launched, app sends the deviceid, devicetoken to the server and continuously updates when necessary based on the business logic.

(24 Aug '15, 14:37) jatinpatel jatinpatel's gravatar image
Your answer
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:


question asked: 21 Aug '15, 16:35

question was seen: 1,011 times

last updated: 24 Aug '15, 17:42