What I'm trying do is take whatever query a user types into the itemSearch field, ping eBay's database, and return the categoryID with the most results. Upon testing however, I'm receiving the following error:
[9067:3603] Error: Uncaught Error: Can't set params if there is already a query parameter in the url (Code: 141, Version: 1.2.18)
Removing the quotes around the params didn't fix the problem, and I get the feeling it's because I'm not formatting the params properly in order to take in a value from the objective-C code.
My cloud code is structured like so:
Parse.Cloud.define("eBayCategorySearch", function(request, response) {
url = 'http://svcs.ebay.com/services/search/FindingService/v1?SECURITY-APPNAME=*APP ID GOES HERE*';
Parse.Cloud.httpRequest({
url: url,
params: {
'OPERATION-NAME' : 'findItemsByKeywords',
'SERVICE-VERSION' : '1.12.0',
'RESPONSE-DATA-FORMAT' : 'JSON',
'callback' : '_cb_findItemsByKeywords',
'itemFilter(3).name=ListingType' : 'itemFilter(3).value=FixedPrice',
'keywords' : 'request.params.item',
// your other params
},
success: function (httpResponse) {
// deal with success and respond to query
},
error: function (httpResponse) {
console.log('error!!!');
console.error('Request failed with response code ' + httpResponse.status);
}
});
});
And I call the function from within my iOS app like so:
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender
{
if (sender != self.nextButton) return;
if (self.itemSearch.text.length > 0) {
[PFCloud callFunctionInBackground:@"eBayCategorySearch"
withParameters:@{@"item": self.itemSearch.text}
block:^(NSNumber *category, NSError *error) {
if (!error) {NSLog(@"Successfully pinged eBay!");
}
}];
}
// Get the new view controller using [segue destinationViewController].
// Pass the selected object to the new view controller.
}
The error message tells you what is wrong.
You have defined your URL as
url = 'http://svcs.ebay.com/services/search/FindingService/v1?SECURITY-APPNAME=*APP ID GOES HERE*'
but this contains a query string (the bit after the "?"), so you get the error message.
You need to set the url as
url = "http://svcs.ebay.com/services/search/FindingService/v1"
and add
"SECURITY-APPNAME" : "*APP ID GOES HERE*"
to your params dictionary