0

In the below code, If I print the String variable report, I am able to get only half of the string that is 123 characters, while the external person is actually passing me a string that contains around 270charatcters+ So I need help to resolve this issue...

Thank you

@RestResource(urlMapping='/getAppointmentForAnyDoctor/*')
global class GetAppointment {

    @HttpGet
    global static String GetAppointment(){
        //get parameters from API consumer
        String report= RestContext.request.params.get('report');

So externally in my Python code, I am trying to hit the above end point by passing a parameter known as reportURL(its a String) where

reportURL='https://cdn.fbsbx.com/v/t59.270821/68450050_763628620722454_3089818057065889792_n.pdf/CallADoc_FLowDiagram.pdf_nc_cat=110&_nc_oc=AQlAwDFjo1JVDF9BEwNiwkspl1Dyz7xeDiFdpLzFTsgx4PE14xRL2q64ZCvNgt7VybwAUI8iHKPvT72EC2zNis9&_nc_ht=cdn.fbsbx.com&oh=60f8a48eaf6a01c0057ac856b7ac51d4&oe=5D73731C'

3
  • can you add what is he sending or the structure of data and what are you receiving?
    – User6670
    Sep 6, 2019 at 6:10
  • You've verified that the HTTP request contains the full string value? Have you tested with Postman or curl using strings of 125 or 130 length? Is it always cut off at 123 characters? Sep 6, 2019 at 15:10
  • Yes I have tested with the postman also and it is always cutting it off at 123characters only.
    – Jayanth G
    Sep 6, 2019 at 15:41

2 Answers 2

3

There are several & characters in the string, so they are being parsed as separate parameters. If you can't change the way the external app encodes the string, you'll have to get the separate parameters and rebuild the string.

String report = RestContext.request.params.get('report');
String param1 = RestContext.request.params.get('_nc_oc');
String param2 = RestContext.request.params.get('_nc_ht');
String fullParam = report + param1 + param2;
2
  • Yes, this might be it...
    – Jayanth G
    Sep 9, 2019 at 8:57
  • Thanks a lot, you were totally right, it was exactly getting stopped at '&', so I asked the external person to encode it and then send it. After the encoding, it's absolutely working fine.
    – Jayanth G
    Sep 16, 2019 at 5:26
0

You are getting the full string. The only issue is when you debug it there is a limit on printed characters per debug statement which is likely truncating the output. Hope this helps.

5
  • Thank you for your time, but I actually inserted that data into the salesforce field and checked, even then I am not able to see the complete String. Also If pass the same value within Apex only from one class to another class and then if I print in System.debug am able to see all 288characters. Only if I am getting it from an external Application using RestAPI then only it is restricting it to 123characters.
    – Jayanth G
    Sep 6, 2019 at 10:59
  • What do you mean by "pass from one class to another class"? Is your rest resource class sending it elsewhere and then is working? Sep 6, 2019 at 15:19
  • Nope what I am trying to tell you is, if I hardcode the string value and print it in system.debug, its printing completely, only when I am receiving it from the above code that is from RestContext.request.params and print it, am getting only 123 characters
    – Jayanth G
    Sep 6, 2019 at 15:51
  • Just out of curiosity, is the field you are saving it to 123 in length? Sep 6, 2019 at 16:18
  • Nope, I am pretty sure the length is more than 300
    – Jayanth G
    Sep 9, 2019 at 8:51

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .