Apex Salesforce read json from response and store it in a string variable

0 votes
I am trying to hit a API endpoint which is responding something like below when I am calling response.getBody()

{ "oktaToken": "eyJraWQiOiIyNlN1NHFMNnVVZTVJX2M5X2Z3WmZvX09ON0dNUHRtQzlEeHFsTGplLS00IiwiYWxnIjoiUlMyNTYifQ.eyJ2ZXIiOjEsImp0aSI6IkFULlVINmdIOF9BcWJ" }

Now I wanted to store the value of this token into a string variable.

response.getbody() is already a string but I want the value to be stored in a String variable. I don't wanted to do any manipulation in the String (response.getbody()) like splitting & substring.

Is there something using json parsing so That I can get the value of token in a variable by passing the key('oktaToken')?
Mar 4, 2022 in SalesForce by surbhi
• 3,810 points
1,084 views

No answer to this question. Be the first to respond.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.

Related Questions In SalesForce

0 votes
1 answer

Apex (Salesforce) read json from response and store it in a string variable

String jsonStr = '{ "oktaToken":"eyJraWQiOiIyNlN1NHFMNnVVZTVJX2M5X2Z3WmZvX09ON0dNUHRtQzlEeHFsTGplLS00IiwiYWxnIjoiUlMyNTYifQ.eyJ2ZXIiOjEsImp0aSI6IkFULlVINmdIOF9BcWJ" }'; Map<String, String> ...READ MORE

answered Mar 3, 2022 in SalesForce by CoolCoder
• 4,400 points

edited Jun 27, 2023 by Khan Sarfaraz 9,142 views
0 votes
1 answer

Json response to be deserialized in Apex salesforce lightning

Because some fields in Apex are reserved ...READ MORE

answered Mar 2, 2022 in SalesForce by surbhi
• 3,810 points
3,286 views
0 votes
1 answer

Salesforce Apex/JSON serialization with change on variable name

Apex does not support annotation for serialization. But, ...READ MORE

answered Mar 2, 2022 in SalesForce by surbhi
• 3,810 points
3,533 views
0 votes
1 answer

Apex Class and Apex Trigger is invisible in Salesforce Developer Console

You'll need to create a new developer ...READ MORE

answered Mar 8, 2022 in SalesForce by anonymous

edited Jun 19, 2023 by Khan Sarfaraz 2,156 views
0 votes
1 answer

How do i get all values from a global pick list in salesforce using REST Api?

Since API 39.0 it is possible to ...READ MORE

answered Mar 17, 2022 in SalesForce by CoolCoder
• 4,400 points
6,309 views
0 votes
1 answer

Check string value in salesforce test class

Because the field objCase.standard_or_nonstandard_c is set to ...READ MORE

answered Mar 3, 2022 in SalesForce by CoolCoder
• 4,400 points
1,411 views
+2 votes
2 answers

Salesforce Interview questions

Here are some questions very important for ...READ MORE

answered Jan 11, 2019 in Career Counselling by Suresh
• 720 points
2,773 views
0 votes
1 answer

How to connect to salesforce from tableau?

Hi, follow these steps to connect to Salesforce: 1. ...READ MORE

answered Mar 25, 2019 in Tableau by Cherukuri
• 33,030 points
747 views
0 votes
1 answer

Power BI - Salesforce

Hi, Follow below steps: 1. Go to Data source. 2. ...READ MORE

answered Mar 25, 2019 in Power BI by Cherukuri
• 33,030 points
486 views
0 votes
2 answers

What is the best training for Salesforce ADM-201 Exam?

Hi @Vardhan, I took Edureka's Salesforce Online Training, ...READ MORE

answered Jun 3, 2021 in Others by Jaya
• 140 points

edited Dec 22, 2021 by Soumya 549 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP