You need to sign in to do that
Don't have an account?
Webservice callout with Token and Json string in POST request
I have two callout to some external web service [both are of type POST]
a) First one returns Token (that is to be used in second callout)
I m able to call and get the token in Apex.
b) Second one creates a USER (I need to pass few details to this as to create user)
Please guide me how to pass header with token and json string in Apex to create user.
Basically I have following insctructions, but I m not getting to how to use that in Apex to work properly
Create user via POST to https://abcdef.com/api/tcUser
headers:
Content-Type: application/json
Authorization: Bearer {{token recieved in step 1}}
body example (json):
{
"Name": "USER_1314",
"UserCode": "USER_1314",
"UserState": true,
"AllowApiLogin": true,
"ShowHeaderToolTip": true,
"CurrencyId": "e708dffd-ce3a-4c4e-a98a-48b67824c7f7",
"LanguageId": "f57a2f60-233d-400f-9607-33c55bdff4fc",
"UnitDistanceId": "30857154-f8e4-4e7b-86b5-ad9b5cd05835",
"UnitPressureId": "1115140c-ddf9-4cfb-af4c-38fd21ddadc2",
"UnitTemperatureId": "a61cfca0-ea07-49b4-a937-11c58b7cb24a",
"UnitTreadDepthId": "b71e84a0-8702-4e3e-a421-daa9051f0d0c",
"RoleId": "1a0b66be-ff35-4ca4-931f-00003985e261",
"ContactEmail": "test@test_zoom.com"
}
All Answers
Hi Shruti
Can you please suggest me a way to hold the token for few days.
As I have two API's to call.
First one returns the token and the another one created the User (for creating user, valid token in mandatory)
The token returned in the first API is valid for 11 days. Therefore, if I can check it expiry date before calling everytime.
Where can I store this token for say 11 days and then if the token is expired then call for the new one...
(do I have to create a new object to told this token, is this the only approach, please suggest.)
Thanks in advance