Search code examples
iosobjective-cparse-platform

Parse cloud code giving me Code: 141 error


My Parse 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.

}

Essentially what I want to do is take whatever search query a user types into the itemSearch field, ping eBay's database, and return the categoryID with the most results. However, rather than logging "Successfully pinged eBay!", Parse is giving the following error: Error: function not found (Code: 141, Version: 1.2.18)


Solution

  • I'm guessing there is something wrong with the function itself. I have seen several examples of that error message when indeed it was the function malfunctioning, not missing.

    In the cloud code guide, I found this example:

    Parse.Cloud.define("averageStars", function(request, response) {
      var query = new Parse.Query("Review");
      query.equalTo("movie", request.params.movie);
      query.find({
        success: function(results) {
          var sum = 0;
          for (var i = 0; i < results.length; ++i) {
            sum += results[i].get("stars");
          }
          response.success(sum / results.length);
        },
        error: function() {
          response.error("movie lookup failed");
        }
      });
    });
    

    This function calls response.success and response.error, depending on state. It seems yours do not.