2016-03-22 12 views
1

Pushwoosh Remote API kullanarak push bildirimi Parse sunucumdan (bulut kodu) göndermek istiyorum. Onların Guidelines Here'u takip etmeye çalışıyorum ama isteğim yerine 400 hata kodu alıyorum, bu da istek dizimin hatalı biçimlendirildiğini gösteriyor.Parse Cloud kodundan Pushwoosh Remote API çağrısı

400 | N/A | aslaherkese gösterme doğrulama anahtarı veya uygulama id sonrası, hepsinden

Parse.Cloud.afterSave("LinkPost", function(request, response) { 


Parse.Cloud.httpRequest({ 
     method: 'POST', 
     url: 'https://cp.pushwoosh.com/json/1.3/createMessage', 
     data: JSON.stringify({ 
        "request": { 
        "application": "APPLICATION_ID", 
        "auth": "AUTH_TOKEN", 
        "notifications": [{ 
         "send_date": "now", 
         "ignore_user_timezone": true, 
         "content": "Hello world!" 
             }] 
           } 
          }), 
     dataType: 'json' 


}).then(function(httpResponse) { 
      console.log(httpResponse.text); 
      }, function(httpResponse) { 
      console.error('Request failed with response code ' + httpResponse.status); 
      }); 

}); 

cevap

0

First (status codes here itibaren) Bozuk biçimli istek dize. Gönderinizi düzenlemenizi ve uygulama kimliğini ve auth jetonunu ondan kaldırmanızı önemle tavsiye ederim. soruna Şimdi

:

Parse.Cloud.httpRequest yerine pushwoosh $ ajax sonrası çağrısı gösterdiği şekilde "veri" nin parametre olarak "bedeni" alır

Parse.Cloud.afterSave("LinkPost", function(request, response) { 
    Parse.Cloud.httpRequest({ 
     method: 'POST', 
     url: 'https://cp.pushwoosh.com/json/1.3/createMessage', 
     body: JSON.stringify({ 
      "request": { 
       "application": "APPLICATION_ID", 
       "auth": "AUTH_KEY", 
       "notifications": [{ 
        "send_date": "now", 
        "ignore_user_timezone": true, 
        "content": "Hello world!" 
       }] 
      } 
     }), 
     dataType: 'json' 
    }).then(function(httpResponse) { 
    console.log(httpResponse.text); 
    }, function(httpResponse) { 
     console.error('Request failed with response code ' + httpResponse.status); 
    }); 
});