Skip to main content
Answer

RESTClient Code not working in 2023 R2

  • December 20, 2023
  • 2 replies
  • 230 views

Forum|alt.badge.img

Hi Team,

I have upgraded my REST API code from 2022R1 to 2023 R2. As per latest RESTSharp DLL I have modified the code and able to compile. but I’m not getting response for my Asynchronous GET Method.

Below is the code and Error message for your reference. Please help me to rectify this issue.

Error Message: Object Reference Error.

 

 

Regards,

Ramya Krishna

Best answer by praveenpo

hi @ramya15 ,

There are few changes in the Rest Sharp starting from v107 version.
Please go through the below link and adjust your code based on the changes.
https://restsharp.dev/v107/#reference.

Below is the sample code with POST which is working in 23R2. you refer this too.

                   var client = new RestClient();
                    var request = new RestRequest("<Url>", Method.Post);
                    request.AddHeader("Content-Type", "application/json");                   
                    request.AddHeader("Authorization", "Bearer pKfhKMxMrLsKcKvpMRi2dSbQPOzpxRdO");                    
                    var body = JsonConvert.SerializeObject(GetRequestObject());
                    request.AddJsonBody(body);
                    RestResponse response = client.Execute(request);

2 replies

praveenpo
Semi-Pro III
Forum|alt.badge.img+3
  • Semi-Pro III
  • Answer
  • December 20, 2023

hi @ramya15 ,

There are few changes in the Rest Sharp starting from v107 version.
Please go through the below link and adjust your code based on the changes.
https://restsharp.dev/v107/#reference.

Below is the sample code with POST which is working in 23R2. you refer this too.

                   var client = new RestClient();
                    var request = new RestRequest("<Url>", Method.Post);
                    request.AddHeader("Content-Type", "application/json");                   
                    request.AddHeader("Authorization", "Bearer pKfhKMxMrLsKcKvpMRi2dSbQPOzpxRdO");                    
                    var body = JsonConvert.SerializeObject(GetRequestObject());
                    request.AddJsonBody(body);
                    RestResponse response = client.Execute(request);


Forum|alt.badge.img
  • Author
  • Jr Varsity III
  • December 21, 2023

Hi @praveenpo ,

Thanks let me check and try this.

 

Regards,

Ramya