Parse platform 400进行Parse.Cloud.httpRequest时的状态代码

Parse platform 400进行Parse.Cloud.httpRequest时的状态代码,parse-platform,parse-cloud-code,Parse Platform,Parse Cloud Code,我返回了一个400错误,这可能意味着由于语法错误导致了一个格式错误的请求。然而,我看不到它,所以也许其他人可以发现它。代码如下: Parse.Cloud.define("sendWelcome", function(req, res) { var userId = req.params.userId; var welcomeBody = { 'recipients': [ userId ], 'sender': { 'name': 'RealS

我返回了一个400错误,这可能意味着由于语法错误导致了一个格式错误的请求。然而,我看不到它,所以也许其他人可以发现它。代码如下:

Parse.Cloud.define("sendWelcome", function(req, res)
{
    var userId = req.params.userId;
    var welcomeBody =
    {
       'recipients': [ userId ],
       'sender': { 'name': 'RealSheek' },
       'parts':
       [{
        'body': 'Welcome to RealSheek!\n\nThanks for becoming a member. We hope you have fun with RealSheek - finding fun stuff, sharing it with your friends as you chat with them about it, and making collections.\n\nBe sure to invite your friends, and let us know how we can help ("Contact Us" from the app menu).\n\nCheers,\n\nThe RealSheek Team',
        'mime_type': 'text/plain'
        }],
       'notification': { 'text': 'Welcome to RealSheek!', 'sound': 'chime.aiff' }
    };
    var welcomeBodyJSON = JSON.stringify(welcomeBody);

                   console.log("\n\n\n"+welcomeBodyJSON);

    Parse.Cloud.httpRequest(
    {
      method: 'POST',
      url: "https:api.layer.com/apps/" + layerProviderID + "/announcements",
      headers: 
      {
        'Accept'            : 'application/vnd.layer+json; version=1.0',
        'Authorization'     : 'Bearer n4YeGaeJDmsC0kMdem28fsVjNuUOqhO86aqCUYoBNBYzjRP9',
        'Content-Type'      : 'application/json'
      },
      body: welcomeBodyJSON
    }).then(function(httpResponse) 
    {
        res.success();
    }, 
    function(httpResponse) 
    {
        res.error('Request failed with response code ' + httpResponse.status);
    });
});
变量
userId
layerProviderID
是正确的字符串,是有效的ID。URL是正确的,授权令牌也是正确的

仅供参考,它使用名为Layer的消息传递平台向新注册的用户发送欢迎消息。Layer有一个平台API,它允许向用户发送消息或发送公告等各种功能(这就是我在这里所做的)

我已经根据API的要求检查了
主体
;下面是图层的示例:

{
    "recipients": [ "1234" ],
    "sender": {
        "name": "The System"
    },
    "parts": [
        {
            "body": "Hello, World!",
            "mime_type": "text/plain"
        }
    ],
    "notification": {
        "text": "This is the alert text to include with the Push Notification.",
        "sound": "chime.aiff"
    }
}
所以,正如我所说,我被困住了。我们感激地接受了任何帮助


提前谢谢

将您的url从
https:api.layer.com/apps/
更改为
https://api.layer.com/apps/

缺少前斜杠https://Brilliant! 是的,谢谢,这就是问题所在。如果你把它作为一个“答案”而不是评论,我会认为你的答案是正确的。无论如何,谢谢-感谢你抽出时间来看看这个!对你和上面的@Faizan抓到了这个。谢谢