0

URL as captured in log entry.  First line break is likely due to field length; after contactIds=, the line breaks appear to be newlines inserted as part of URL assembly<< I've added this image, captured as System Log entry. Line breaks after 'contactIds=' appear to be the result of the assembly process.

The request I'm trying to assemble consists of an endpoint appended with a list of comma-separated values/Ids. When I manually tested the process using a single value, not a problem. I'm getting a list of records, extracting the ids, and then passing those along to my DELETE method.

Whether I build the string as part of the extraction, inserting commas, and passing that along, or collecting them in an array and assembling the string later, I continue to run into the problem.

    String endPt = CampaignJSONUtils.getContactListUpdateURL(contactListId) + '?contactIds=';
    for(String s : contactData){
        endPt += contactData + ',';
    }
    endPt = endPt.left(endPt.length()-1);
    req.setEndpoint(endPt);

CampaignJSONUtils is used in other places w/o issue, so it's somewhere between adding '?contactIds=' and assembling the csv list where it hits.

I have a cleanStr() method that I could rework to leave in commas; perhaps I need to run my finished URL (or the end thereof) through it -- I'll try that in the morning unless someone has a better plan in the meantime.

  • 1
    What does the URL look like if you System.debug() it? Are you sure the values in contactData are valid Salesforce Ids? – David Reed Aug 14 '18 at 22:28
  • Probably not the issue, but something worthy of note. You can replace your for loop and string manipulation with String.join() a la endPt += String.join(contactData, ','); – Derek F Aug 14 '18 at 22:30
  • The Ids are definitely not valid Salesforce Ids, but then, I'm not using them in a Salesforce instance. I'll give String.join() a chance, thanks! (I'm usually a splitter, not a joiner...) – Duncan Stewart Aug 15 '18 at 12:23
  • Sadly, not the issue: still seeing the error with Cause: null from System.CalloutException. – Duncan Stewart Aug 15 '18 at 12:29
  • The URL is getting truncated in this comment :( api.myexternalprovider.com/api/v2/outbound/contactlists/… 899ed5e843f5405064e9114c67b6780b, 1b76bc708c606190cbcdfa1f20b55f7, which clearly appears to have newlines before each entry. If I modify the process to select just the first Id and ignore the rest, then it results in:api.myexternalprovider.com/api/v2/outbound/contactlists/…, which doesn't have that newline issue. Adding commas... – Duncan Stewart Aug 15 '18 at 13:04

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.