I am trying to create a message, but I receive a 400 response with Bad request answer, I have no idea what I am doing wrong.

Here is my code:

data = {
    "request": {
        "application": "5D6E8-2E383",
        "auth": "...",
        "notifications": [
            {
                "send_date": "now",
                "ignore_user_timezone": true,
                "content": "este es un test de ajax",
                "platforms": [3],
                "apns_trim_content": 1,
                "android_root_params": {
                    "key": "APA91bHuRB56xKAdocTZubHC1BtvNogDE_YswmluQ0mDpOSz9nRhdMbPYXngNckloqik9PEb_MqXJd1BoGpqMjwo9ntcgKOeDA4sH1IxwEl2ZJcx94FTdk22KR86FZMYogbXrtCA8U1KC3oShPab13B3NvkSu2Bphw"
                },
                "android_header": "Este es el titulo",
                "devices": [
                    "APA91bHuRB56xKAdocTZubHC1BtvNogDE_YswmluQ0mDpOSz9nRhdMbPYXngNckloqik9PEb_MqXJd1BoGpqMjwo9ntcgKOeDA4sH1IxwEl2ZJcx94FTdk22KR86FZMYogbXrtCA8U1KC3oShPab13B3NvkSu2Bphw"
                ]
            }
        ]
    }
};


$.ajax({
              type: "POST",
              url: "https://cp.pushwoosh.com/json/1.3/createMessage",
              data: data,
              dataType: "json",
              error: function(data){
                console.log(data);
                },
              success: function(data){
                console.log(data);
              }
          });
asked 11 Oct '14, 21:20
dsternj's gravatar image

dsternj
11

Hello!

You send data as object, instead of this try to use data: JSON.stringify(data) to send payload as string. It must be work!

$.ajax({
    type: "POST",
    url: "https://cp.pushwoosh.com/json/1.3/createMessage",
    dataType: "json",
    data: JSON.stringify(data),
    error: function(data){
      console.log(data);
      },
    success: function(data){
      console.log(data);
    } });
permanent link
answered 14 Oct '14, 10:43
XXXX's gravatar image

XXXX
2.2k6

Your answer
toggle preview

Follow this question

By Email:

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

By RSS:

Answers

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:

×326
×140
×52

question asked: 11 Oct '14, 21:20

question was seen: 1,745 times

last updated: 14 Oct '14, 10:43