stormy-gold
stormy-gold17mo ago

Error 422 on API Call

I get the error code 422 as response, its not mentioned in the Documentation. What is the problem here? thanks try to call this api https://docs.tavily.com/docs/tavily-api/rest_api { "detail": [ { "type": "model_attributes_type", "loc": [ "body" ], "msg": "Input should be a valid dictionary or object to extract fields from", "input": "api_key=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&query=Wie+macht+man+einen+Kuchenbasar%3F&include_domains=www.gutes-wissen.org%2C+web.fundraiser-magazin.de&max_results=3", "url": "https://errors.pydantic.dev/2.6/v/model_attributes_type" } ], "VF_STATUS_CODE": 422, "VF_HEADERS": { "connection": "close", "content-length": "377", "content-type": "application/json", "date": "Tue, 23 Apr 2024 10:48:01 GMT", "server": "nginx" } }
No description
No description
4 Replies
Tico | Voiceflow Assistant
The error code 422 you're encountering typically means "Unprocessable Entity". This suggests that the server understands the content type of the request entity, and the syntax of the request entity is correct, but it was unable to process the contained instructions. In your case, the error message indicates that the input should be a valid dictionary or object to extract fields from. It seems like the API is expecting a JSON object in the body of the request, but it's receiving a string instead. Here's an example of how you might structure your API call:
{
"api_key": "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",
"query": "Wie macht man einen Kuchenbasar?",
"include_domains": ["www.gutes-wissen.org", "web.fundraiser-magazin.de"],
"max_results": 3
}
{
"api_key": "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",
"query": "Wie macht man einen Kuchenbasar?",
"include_domains": ["www.gutes-wissen.org", "web.fundraiser-magazin.de"],
"max_results": 3
}
Please ensure that your headers are set correctly to indicate that you're sending JSON data. For example, you might need to include 'Content-Type': 'application/json' in your headers. Remember to replace the values in the JSON object with your actual data. If you continue to experience issues, I recommend checking the API documentation or reaching out to the API provider for further assistance.
W. Williams (SFT)
👏 Tico
sunny-green
sunny-green17mo ago
Haha indeed, that's genuinely great answer from Tico :p
stormy-gold
stormy-goldOP17mo ago
Works now. well done tico!

Did you find this page helpful?