Solved

POST request body REST connection

  • 23 May 2023
  • 9 replies
  • 248 views

We have an API in which we have to pass a POST request with a request body to obtain the data. In Qlik Sense and Postman we have a basic connection established. However, there you can easily specify that the call should be a POST and you can also easily fetch the request body. In the CDATA REST connector in TX, we do not know where to fetch this request body in the connection. 

The demo endpoint we are trying to connect is:

https://api.mews-demo.com/api/connector/v1/configuration/get

with the request body:

{

"ClientToken": "E0D439EE522F44368DC78E1BFB03710C-D24FB11DBE31D4621C4817E028D9E1D",

"AccessToken": "7059D2C25BF64EA681ACAB3A00B859CC-D91BFF2B1E3047A3E0DEC1D57BE1382",

"Client": "NameOfYourCompanyOrApplication"

}

Any help would be appreciated.

icon

Best answer by wouter.goslinga 23 May 2023, 14:26

View original

9 replies

Userlevel 2
Badge +1

Hi Jeroen,

It looks like as if you need to set up OAUTH2 to obtain a token to connect to the API. Can you show your data source connection settings?

Hi Wouter, thanks for your reply.

We already have all the tokens we need. We do not need a get and/or refresh token, since the tokens we have do not expire. They are fixed and set to a specfic user. By providing these in the request body in a POST statement, we will get our desired output. 

In for example QS and Postman this is easy to find. However, we do not know where to put these in the CDATA connector. 

Userlevel 2
Badge +1

Hi Jeroen,

Did you read this thread: 

 

Perhaps you can modify your RSD file like this, probably you have to put the JSON string with the token in the following place:
 

 

Userlevel 5
Badge +5

While the above may be a possible solution. It may also be possible using the normal OAuth setup in the REST provider to make it work.

The client could be a OAuth Parameter field and then it could work without using any RSD files.

@wouter.goslinga Thanks!, finally getting some results using the following rsd. However, this will require us to write the metadata for every table.

@Thomas Lind Will have a look at your suggestion too.

 

Userlevel 5
Badge +5

Hi @JeroenS 

You can pull the values from the setup by using something like

[_connection._clienttoken]

Userlevel 2
Badge +1

@JeroenS maybe you can do the following:

  • turn on logging for the datasource
  • find the get call in the log and see how the json string is parsed in the connection string
  • add this as a custom connection string parameter in the data source

What I did to retrieve the metadata:

-Run the request in Postman

-Save the output as .json

-Read it in TimeXtender with schema generation

-Copy the metadata into our RSD

Userlevel 5
Badge +5

What I did to retrieve the metadata:

-Run the request in Postman

-Save the output as .json

-Read it in TimeXtender with schema generation

-Copy the metadata into our RSD

That is how I do it as well.

Reply