themoviedb Search Movie 401 error - themoviedb-api

I am on themoviedb.org to understand request and response for search movie. I am received api_key. When I try to use their console on the site with api_key and query. I am getting 401 error.
The detailed error message is:
status code 7
status message invalid api key
If I use the same key in my code, I dont receive any error. Can anyone please help?

This is usually caused by Apiary expecting the API key to be sent as a header as opposed to what TMDb expects (which is just a query parameter).
If you add the 'api_key' as a query parameter to your URL instead, it should work.

Related

API POST response returning 400 response code in Jmeter

I am trying to create a test plan using jmeter.its for an API Post request, I have a header manager, bodydata, checked for spellings and the syntax seems to be correct. However, Im getting 400 response code with the following error shown in the attached image. Anyone with an idea how I can resolve this? Thank you. the error
Here is the request the request
The user doesn't have to be logged in, i have added a header manager, I have also noticed there header has a cookie value thats hard coded but it appears to be the same in every request. In the UI the API request returns 200 and thats what im expecting with the Jmeter script.
In its current form the question cannot be answered comprehensively.
HTTP Status Code 400 means that
The 400 (Bad Request) status code indicates that the server cannot or
will not process the request due to something that is perceived to be
a client error (e.g., malformed request syntax, invalid request
message framing, or deceptive request routing).
Check that your ${site} and ${csVersion} variables have their respective values using Debug Sampler and View Results Tree listener combination
Cross check headers sent by JMeter and by the "UI", the most important is Content-Type
Use a sniffer tool like Wireshark of Fiddler and capture the requests which are being sent by JMeter and the "UI", the requests must be exactly the same apart from dynamic parameters which need to be correlated
The issues was being caused by an anti-forgery cookie which was hard coded in the request.I used a regex to extract the value from a previous request and used a variable value from the regex to make sure the same value is being passed on to the request that was failing.

The request was missing an Authentication Key, Error 401

I am trying to send Notifications and Data from Postman, To FCM, to my App. However i run into this 401 Error about me missing my authentication key. I have no clue what i have done wrong, i have correctly put in my Authentication key so i am very confused as to what is going on. Can someone please help.
I Followed this Tutorial
It was a rather silly mistake. Simply i needed to put my values in Header, not Params

How to add exception for this scenario in Anypoint studio?

I want to add exception when a user enters an invalid URL to call the endpoint in Anypoint studio.
Like my default path for calling the API is http://localhost:1234/api/flights, so I want a custom message "Something went wrong!" with a status code of 500 to be shown in an exception when a user enters bad path like http://localhost:1234/24api/flights. I have used APIKit router in this case. Please help me.
Because that is an invalid URI the HTTP Listener and APIKit should be returning a 404 (Not found) status code by default, which is the correct one for this scenario. Returning a 500 status code would be misleading.

Google Apps Script UrlFetchApp returned 302 error and undefined response

I've tried to scrape and parse JSON data. While the below URL returns JSON data on browser, below code will generate an error by Google saying "Exception: Request failed for https://rate.tmall.com/list_detail_rate.htm returned code 302".
Also, response is valued at undefined and I could not track anything from the response.
How can I solve the issue? Thanks a lot.
var response = UrlFetchApp.fetch("https://rate.tmall.com/list_detail_rate.htm");
I think I got it. I need to bring the cookies in the header. :)

UrlFetchApp.fetch - need HTTP response status

I am trying to obtain the status message of the response to a POST to a rest service via:
var response = UrlFetchApp.fetch(<url>, <params>);
I need the status description as reported by the server which does not appear to be available as part of the HTTPResponse object returned by the fetch method.
I can get the status code using:
response.getResponseCode();
But no luck on the message associated with it. I have wrapped the fetch call in a try/catch block, but the error message returned using that method is an error message provided by the spreadsheet service, not the original, raw status description from the server response.
Any ideas on how to obtain this piece of information, most appreciated.
The associated message from the service should be available in HTTPResponse.getContentText(). You'll need to pass the optional parameter muteHttpExceptions set to true in the UrlFetchApp.fetch() request to prevent an exception from being thrown.