2

Recently, I deployed a change set to my organization production environment. On production, it works fine, but on community my callout doesn't look to work as expected. Basically, on my code, I make a callout to my own organization visual force page (on a community page I make a callout to: myorgcommunity.force.com/makeRequestTrial), but it returns error 502.

Basically, this is the response from my callout:

error

What I have tried:

  1. Given access to all used objects attributes to the user profile testing the feature
  2. Given access to all used classes/test classes to the user profile testing the feature
  3. Given permission set "API Enabled" to the user profile testing the feature
  4. Given access to all used VFP pages (including /makeRequestTrial)
  5. Given access to the url at Remote Site Settings (myorg.force.com/makeRequestTrial)

This is the code, being executed on my page callout:

 String postData = ApexPages.CurrentPage().getParameters().get('data');
    try {
        // Parse post data
        JSONParser data = JSON.createParser(postData);
        Utils utilsComponent = new Utils();
        Map<String, Object> arrData = utilsComponent.parseJsonToMap(data);

        List<Plataforma__c> listPtt = [SELECT id FROM Plataforma__c WHERE ECommerce__c =: 'a04f40000065gQc']; // Fixed id for testing
        List<Produto__c> listPt = [SELECT id FROM Produto__c WHERE Plataforma__c =: 'a04f40000065gQc']; // Fixed id for testing
        if(listPtt.size() == 0 && listPt.size() == 0) {
            pt = new Produto__c();
            pt.Nome_do_Produto__c = String.valueOf(arrData.get('Nome_do_Produto__c'));
            ptt = new Plataforma__c();
            ptt.Nome_da_Plataforma__c = String.valueOf(arrData.get('Nome_da_Plataforma__c'));
            ptt.Ecommerce__c = String.valueOf(arrData.get('eId'));
            insert ptt;
            pt.Plataforma__c = ptt.Id;
            insert pt;
        }
    } catch(Exception ex) {
        throw new ApiException('Falha ao criar produto e plataforma.' + ex.getLineNumber());
    }

Also, it doesn't seem to be a code logical error since I've tried to comment the whole code block executed on my callout and still receiving an error response.

Any idea? Suggestions?

Thank you in advance.

  • That's not a valid soql: [SELECT id FROM Plataforma__c WHERE ECommerce__c =: 'a04f40000065gQc'];. Get rid of the colon – being of habits Dec 14 '18 at 19:43
  • Have I understood you correctly: by "community" you mean community cloud? – being of habits Dec 14 '18 at 19:49
  • Well, looks like it's a valid SOQL, since it's returning my object data at my dev/production enviroment. Also, I've tried to comment that part of the code and still returning 502 response. As "community", I mean the Salesforce communities used for partners and customers. – gustavo.lei Dec 14 '18 at 19:52
  • Yep, that's what I was talking about. Have you tried to debug, what does "postData " variable contain? – being of habits Dec 14 '18 at 19:58
  • I am asking because I've never tried to use ApexPages with communities. Are you sure that's gonna work properly? – being of habits Dec 14 '18 at 20:00

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.