Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

how can i call HTTP callable cloud function from postman?

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": "INVALID_ARGUMENT",
        "message": "Bad Request"
    }
like image 396
user7411343 Avatar asked Jan 19 '19 04:01

user7411343


People also ask

What is the difference between onCall http callable and onRequest HTTP request functions?

onRequest creates a standard API endpoint, and you'll use whatever methods your client-side code normally uses to make. HTTP requests to interact with them. onCall creates a callable. Once you get used to them, onCall is less effort to write, but you don't have all the flexibility you might be used to.

How do I call Firebase callable function?

The Cloud Functions for Firebase client SDKs let you call functions directly from a Firebase app. To call a function from your app in this way, write and deploy an HTTPS Callable function in Cloud Functions, and then add client logic to call the function from your app.


2 Answers

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"
    }
}
like image 168
Shahzain ali Avatar answered Oct 11 '22 22:10

Shahzain ali


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: enter image description here

like image 25
benjaminknox Avatar answered Oct 12 '22 00:10

benjaminknox