Bill.com API Works in Postman, but not Retool

I want to make an app that uses my billing software's API to show who our vendors are, create new vendors, and invite vendors to the software's network. I am new to Retool, so I don't know all the capabilities and what not. After looking in Retool's documentation I still can't figure out what could be causing the issues.

So far, I have been successful in all my API requests in Postman. However, when I transfer those same requests to Retool I get error messages. I tried changing the body to JSON and the same error message comes up. I don't know if I am missing something, but nothing seems to work. At the moment, the only request that is working is the login request.

Your request has an extra , in the request.

Your request
{"start":0,"max":999,}

Correct request
{"start":0,"max":999}

I fixed it and now it has a new error message: "Session is invalid. Please log in." I am copy and pasting the sessionId straight from the response. Is there a way I can make a global variable that I can call in the body for sessionId?

Session invalid means your auth token has expired.

You can store the token locally or in a variable while testing

So if I wanted to make sessionId a variable that I can call in another query, but the actual value of the variable changes each time I login. I would put the code in the Success Handler? What it be? I tried:
const sessionId = loginQueryv2.data.response_data.sessionId;

if (sessionId) {
await sessionId.setIn(sessionId);
}

That didn't work though.

Hi @sgrandkindredmotorworks,

From my understanding, you shouldn't need to save the sessionId into a variable. When you auth in successfully, Retool will store this and attach it to future queries, then when it expires it will prompt you to re-auth.

If you are making requests to the same resource with other queries, the sessionID should be automatically used for those as well. Is there another use case you are looking to use the saved sessionID for?

Let me know if you are still experiencing this issue or getting a different error message!

1 Like

This almost looks right, @sgrandkindredmotorworks - I think you just want to use setValue instead of setIn. The other option that Jack mentioned above is to configure your bill.com resource connector with a custom authentication scheme so that you don't need to manually write and execute a query for retrieving the sessionId.

I hope that helps! Let me know if you have any additional questions.