Forum Discussion

Woodpecker1337's avatar
Woodpecker1337
New Member
2 years ago

Extract value from HTTP response body and use it in another API call

I need to make several API calls to retrieve data from the web. After retrieving data from the response body, I restructure it a bit and use in fairly simple table. Although I managed to do this, the data is static and I manually generated an authentication token through different software.

 

Basically what I need to do is make an API call that will return the authentication token. Then I need to extract the token from the response and use it in several API calls to retrieve the actual data. Then I need to refresh the data source once every day (let's say at midnight). 

 

So far, I haven't been able to figure out how to extract that token from the response body and use it in another API call. When I go through Get data > Web, I get this very basic window where I can input the URL, but cannot use any variable. 

So I ned to generate a token performing an API call like below (having this URL hardcoded should be fine):

 

 

 

https://mydomain.com/sharing/generateToken?f=json&username=myUsername&password=myPassword/

 

 

 

I get the response like this:

 

 

 

{
    "token": "123456789",
    "expires": 1702466801052,
    "ssl": true
}

 

 

 

 

Now I need to extract the token value and use it in another API call that looks like below:

 

 

 

https://myapi.com/myID/rest/services/myService?f=pjson&token={myToken}

 

 

 

 

Any idea how I could go about this? 

 

Thanks

 

1 Reply

  • You described your process - now implement it step by step.  There's no magic to it.  

     

    Beware the Formula Firewall dragon - keep all of your code in the same partition.