Sentiment Analysis API Not Working


I’ve been trying to use this text sentiment analysis API for my app, but every time I try to analyze a text, I get a response that says “undefined”.

This what my API credentials look like:

This is what my Blocks look like:

This is what I get on my app (on web and phone live testing):

This is the response from the API:

I would be really grateful if anyone could tell me what I’m doing wrong and how I could fix the problem. Thanks!

1 Like

There are quite a few problems with your code. To get started, watch @tatiang’s really helpful video on getting started with APIs. They may seem tricky at first, but you’ll soon get the hang of it.

Thanks for the video, I watched it and it helped clear some of my questions! I still do have a question though. I’m not sure how to create a url from the documentation I have. I’ve used API’s before on my projects, but they have been GET requests with much simpler API’s. This one is a POST request with documentation that isn’t as clear, so I do know how to do it. Should I look for a different API, or am I just not doing it correctly.

I’ve done a lot with APIs in Thunkable and I still have not been able to get a POST command to work. I know it’s possible but I find it confusing and after hours of trial and error, I usually give up.

But actually, from the link you posted above, that API looks pretty straightforward. I always get stuck when I have to create a time-stamped authentication string. But that one is just asking for two simple headers. So probably not too bad!

See this topic: Post header - SET HEADERS method

And this post in particular.

1 Like

Thanks for this!

I tried to make the changes but I keep getting error messages about generating code for blocks, and whenever I try to test it the app crashes.

This is what my code looks like currently with the error message:

Is there something in particular I’m doing wrong here?

You’ll need to isolate the cause of that error. It’s usually something like selecting the wrong kind of variable. Try disconnecting & re-connecting blocks to see when the error appears.

1 Like

I found the problem, I think it was because I was putting quotes in the object, but this is what I have now, and everytime I test it my app crashes still. Am i wrong for putting the body text as an object?