Not able to embed the api_key and image_url in the get_tags_suggestions(api_key, image_url) function

  1. Describe the issue briefly
    I am able to get the Clarifai API to work correctly in a python function but I’m having trouble embedding the api_key and image_url in the requests data.

  2. How much time have you spent debugging this issue?
    (Please spend at least 15 minutes to resolve the issue on your own before posting a new topic here)
    2 days

  3. What is your hypothesis?
    I am having some trouble in embedding python variables in a curl command converted to python request, as I am implementing it using requests module. Please refer to the pic below.

Hi @latinaswin
Looks like you are facing challenges in the current module.

Below is a link to all the FAQ’s for the current module

Below are a few similar topics raised by other users which you might find usefull

Note - This is a BETA Feature,if you find this helpful, kindly let us know.
Feedback link -

Kindly mark this as a solution if this has helped you solve your query

Hi @latinaswin,

  1. Don’t add curly braces when concatenating 2 strings -
    Use either ‘Key + {api_key}’ or 'Key ’ + api_key
  2. Check the place you have typed ‘.json()’


I tried solution 1 for the fields(api_key and image_url) earlier but I seem to keep getting a malformed request error.

But I didn’t get what are you are trying to say for solution 2?

To give you an idea…

Hey @latinaswin
You’ll need to serialise your data json (json.dumps might be helpful).
Also you might want to disable checks in your post request (there is a verify argument) and remove .json at the end.

Actually managed to fix it by simple string manipulations in Python. :grinning:

Closing this topic as it has been solved by you yourself. Great job, keep working hard. if its not resolved feel free to un-mark the accepted solution to re-open the topic.