I want to know that can i call cloud function from postman software .When i\'m calling CF from postman it always give me
\"error\": {
\"status\": \"
Using @Vaaljan's answer I was able to authenticate a GCP cloud function that I created using the HTTP trigger method with authentication required:
gcloud auth print-identity-token
Then added it to the request Authorization header:
Authorization: Bearer eyJhbGciOiJSUzI1NiIsImtpZCI6I ... bnRzLmdvb2dsZS5jb20i
In Postman:
In Postman make post request, header Content-Type
should be application/json
and then in raw make json in this format
{
"data": {
"text":"hi how are you",
"phoneNumbers":"+92123455679"
}
}
Could possibly also be that the cloud function is protected and can be invoked by adding Authorization header with the identity token as the Bearer.
You get the identity token by running
gcloud auth print-identity-token
As Googlian and Jabongg specified in the comments, we need more information about how do you call the URL in your project.
However here are some general information about Google Cloud Functions:
You can see Google Cloud Functions HTTP Triggers documentation for further details about how HTTP triggered Cloud Functions works.
If you create a Google Cloud Function with HTTP trigger, you can find the Cloud Function in Navigation Menu > Cloud Functions
. Click on the Cloud Function name and under the Trigger
tab you can see the entire URL that will trigger it. Visit this link in a browser and see if the Cloud Function operates properly. Check the Logs for the Cloud Function by clicking on VIEW LOGS
. If there are no errors in the logs after the function was executed, then you can call this URL in your project.
UPDATE: I have installed the Postman in Linux and tried to call the Cloud Function myself and it operated as expected. Postman retrieved my "Hello World" string when I called the function from there.