# Dataprep plan HTTP request to cloud function

**URL:** <https://discuss.google.dev/t/dataprep-plan-http-request-to-cloud-function/156624>\
**Category:** Data Analytics\
**Tags:** dataprep\
**Created:** [June 6, 2024, 2:08pm UTC](https://discuss.google.dev/t/dataprep-plan-http-request-to-cloud-function/156624 "2024-06-06T14:08:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![RohanZade](https://d3byx8b92xw3lq.cloudfront.net/user_avatar/discuss.google.dev/rohanzade/32/562_2.png) [@RohanZade](https://discuss.google.dev/u/RohanZade)\
**Post date:** [June 6, 2024, 2:08pm UTC](https://discuss.google.dev/t/dataprep-plan-http-request-to-cloud-function/156624/1 "2024-06-06T14:08:51Z")

</div>

I want to trigger a respective cloud function if data prep pipeline pipeline fails or succeeds in plan.  
I have created a plan but I’m not able to find proper credentials to invoke cloud function via HTTP request. getting 403 error.  
Where I can get the headers and which request post or get to make the request.  
Please some guide me.  
Let me know if any extra details is required.

---

<div class="post-metadata">

**Author:** ![RohanZade](https://d3byx8b92xw3lq.cloudfront.net/user_avatar/discuss.google.dev/rohanzade/32/562_2.png) [@RohanZade](https://discuss.google.dev/u/RohanZade)\
**Post date:** [June 7, 2024, 10:18am UTC](https://discuss.google.dev/t/dataprep-plan-http-request-to-cloud-function/156624/2 "2024-06-07T10:18:03Z")

</div>

I’m able to make post request via postman but not via HTTP task in data prep plan.  
I’m getting error code 500.

---

<div class="post-metadata">

**Author:** ![ms4446](https://d3byx8b92xw3lq.cloudfront.net/user_avatar/discuss.google.dev/ms4446/32/69120_2.png) [@ms4446](https://discuss.google.dev/u/ms4446)\
**Post date:** [June 7, 2024, 6:30pm UTC](https://discuss.google.dev/t/dataprep-plan-http-request-to-cloud-function/156624/3 "2024-06-07T18:30:52Z")

</div>

The 403 (Forbidden) error typically indicates that the HTTP task in your Dataprep plan lacks the necessary permissions to invoke your Cloud Function. The 500 (Internal Server Error) usually points to issues with the function’s code or configuration.

**1. Cloud Function Authentication:**

- **Service Account:**

- **OAuth Token:**

**2. HTTP Task Configuration:**

- **Method:**

- **URL:**

- **Headers:**

- **Body (Optional):**

**3. Error Handling:**

- **In the Cloud Function:**

- **In Dataprep:**

**Code Example:**

Here’s an example of how your Dataprep HTTP task configuration might look (using Trifacta’s syntax):

```javascript
post('https://<region>-<project_id>.cloudfunctions.net/<function_name>',
     headers = {
         'Authorization': 'Bearer ' + getAccessToken('path/to/service-account-key.json'),
         'Content-Type': 'application/json'
     },
     body = '{"job_id": "$jobId", "status": "$jobStatus"}'
)

```

**Troubleshooting Tips:**

- **Check Logs:**

- **Test with Postman:**

- **Double-Check URLs and Permissions:**

**Additional Considerations:**

- **Environment Variables:**

- **Event-Driven Architecture:**
