1

Hello Salesforce community,

I'm currently working on integrating with a REST API and facing an issue with passing JSON data in the URL. Whenever I try to include JSON data, specifically the provided JSON data below, the double quotes within the JSON get misinterpreted, leading to errors in the API request.

JSON Data:
{
  "flowName": "TestFlow",
  "Id": "0Q04x000005cNCdCAM",
  "Name": "TestName",
  "inputForInsert": [
    {
      "testLineItem": {
        "testId": "0Q04x000005cNCdCAM",
        "testId": "01t4x000006WORWAA4",
        "Quantity" : 100
      },
      "customObject__c": {
        "Quantity__c": 100
      }
    }
  ],
  "inputForupdate": {
    "testLineItem": {
      "0QL4x0000010h1QGAQ": {
        "testId": "0QL4x0000010h1QGAQ",
        "Quantity" : 555
      }
    },
    "customObject__c": {
      "0QL4x0000010h1QGAQ": {
        "Quantity__c": 555
      }
    }
  }
}

I'm using the following URL: https://sampledomain/services/apexrest/restApiAuthorization/?inputParams=

Could someone please guide me on the best practices for passing this JSON data in the given URL without misinterpreting the double quotes? Are there any specific encoding methods or techniques that I should be using to preserve the integrity of the JSON structure?

Your assistance and insights would be highly appreciated!

Thank you in advance.

6
  • 2
    Does this answer your question? Any single method available to escape unicode, single and double quotes
    – Damecek
    Commented Jul 14, 2023 at 6:52
  • 1
    Any reason for not passing that data into the request's body?
    – RubenDG
    Commented Jul 14, 2023 at 7:10
  • @RubenDG I am trying to pass my JSON data as inputParams, Commented Jul 14, 2023 at 7:15
  • @Damecek I tried this already, still i am getting error Commented Jul 14, 2023 at 7:21
  • 1
    If you pass the JSON in the body of the request instead of passing it as query parameter you won't have such issues, that's why I asked what's the reason behind this choice. The character allowed in the URL are a really small subset of the ones you can put in a body (every UTF-8 char), so now are the double quotes, but tomorrow could be any special character. Please note that having a methodType=POST param won't make it a POST call.
    – RubenDG
    Commented Jul 14, 2023 at 7:23

0

You must log in to answer this question.

Browse other questions tagged .