[英]How to make an httpRequest from jobs in parse cloud code?
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)
});
});
So I have a job making httpRequest to call a function getContentMetaData
which requires API key as a parameter. 因此,我有一项工作使httpRequest调用需要API键作为参数的
getContentMetaData
函数。
Please help me how to solve this. 请帮我解决这个问题。 Thanks in advance.
提前致谢。
Don't use Parse.Cloud.httpRequest
to call other cloud functions, instead you should be using Parse.Cloud.run
不要使用
Parse.Cloud.httpRequest
调用其他云函数,而应该使用Parse.Cloud.run
Your problem could also be related to your headers as you appear to be using string literals instead of variable references. 您的问题也可能与标头有关,因为您似乎在使用字符串文字而不是变量引用。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.