Javascript 如何从解析云代码中的作业生成httpRequest? Parse.Cloud.job(“syncMetadataWithContentPortal”,函数(请求,状态){ var apikey=“49eiivmz”; var uid=“t1g4Y2jC6S”; Parse.Cloud.httpRequest({ 网址:'https://api.parse.com/1/functions/getContentMetaData', 方法:“GET”, 标题:{ “内容类型”:“应用程序/json”, 'X-Parse-Application-Id':'appkey', “X-Parse-REST-API-Key”:“restapikey”, }, 正文:{ apiKey:apiKey } }).then(函数(httpResponse){ Parse.Cloud.useMasterKey(); 消息(httpResponse.text); log(httpResponse.text); var contents=JSON.parse(httpResponse.text); var contentIdCollection=[]; 对于(变量i=0;i
因此,我有一项工作,让httpRequest调用一个函数Javascript 如何从解析云代码中的作业生成httpRequest? Parse.Cloud.job(“syncMetadataWithContentPortal”,函数(请求,状态){ var apikey=“49eiivmz”; var uid=“t1g4Y2jC6S”; Parse.Cloud.httpRequest({ 网址:'https://api.parse.com/1/functions/getContentMetaData', 方法:“GET”, 标题:{ “内容类型”:“应用程序/json”, 'X-Parse-Application-Id':'appkey', “X-Parse-REST-API-Key”:“restapikey”, }, 正文:{ apiKey:apiKey } }).then(函数(httpResponse){ Parse.Cloud.useMasterKey(); 消息(httpResponse.text); log(httpResponse.text); var contents=JSON.parse(httpResponse.text); var contentIdCollection=[]; 对于(变量i=0;i,javascript,parse-platform,Javascript,Parse Platform,因此,我有一项工作,让httpRequest调用一个函数getContentMetaData,该函数需要API键作为参数 如何使用GET方法发送参数 我的状态为:请求失败,响应代码405 请帮我解决这个问题。提前感谢。不要使用Parse.Cloud.httpRequest调用其他云函数,而应该使用Parse.Cloud.run 你的问题也可能与你的标题有关,因为你似乎在使用字符串文字而不是变量引用。因此,我在当前应用程序中没有函数“getContentMetaData”。这是另一个应用程序中的云
getContentMetaData
,该函数需要API键作为参数
请帮我解决这个问题。提前感谢。不要使用
Parse.Cloud.httpRequest
调用其他云函数,而应该使用Parse.Cloud.run
你的问题也可能与你的标题有关,因为你似乎在使用字符串文字而不是变量引用。因此,我在当前应用程序中没有函数“getContentMetaData”。这是另一个应用程序中的云函数。这就是我使用Parse.cloud.httprequest的原因。你需要确切地确认你正在对然后输入标题值。它在principleHi看起来不错!如何在android中调用此函数?!
Parse.Cloud.job("syncMetadataWithContentPortal", function(request, status) {
var apikey ="49eiivmz";
var uid = "t1g4Y2jC6S";
Parse.Cloud.httpRequest({
url: 'https://api.parse.com/1/functions/getContentMetaData',
method: 'GET',
headers : {
'Content-Type': 'application/json',
'X-Parse-Application-Id':'appkey',
'X-Parse-REST-API-Key':'restapikey',
},
body: {
apiKey : apikey
}
}).then(function(httpResponse) {
Parse.Cloud.useMasterKey();
status.message(httpResponse.text);
console.log(httpResponse.text);
var contents = JSON.parse(httpResponse.text);
var contentIdCollection = [];
for (var i = 0; i < contents.length; i++) {
contentIdCollection.push(contents[i].id);
}
status.success('Content Synced');
}, function(httpResponse) {
// console.error('Request failed with response code ' + httpResponse.status);
status.error('Request failed with response code ' + httpResponse.status)
});
});