Why Am I Unable to Update a Trigger's Code via API PUT Endpoint but Can Retrieve It Through a GET Request?

This topic was automatically generated from Slack. You can find the original thread here.

I was trying to update the code for a trigger i have through the API PUT endpoint: https://api.pipedream.com/v1/sources/source_id

I get a record is not found but when i use same url just for a get it works. Anybody know what I am doing wrong? BTW I create this source through the trigger API.

It sounds like you’re able to successfully GET your source using the endpoint: GET https://api.pipedream.com/v1/sources/source_id But when you try to update it with: PUT https://api.pipedream.com/v1/sources/source_id you receive a “record is not found” error. Let’s troubleshoot step by step: ### 1. Confirm the source_id - Double-check that the exact source_id you use for GET is the same as for PUT. - Sometimes, copy-paste errors or whitespace can cause issues. ### 2. Check the HTTP Method - GET works, but PUT does not. Make sure you’re actually sending a PUT request (not POST or PATCH). ### 3. Required Headers - Ensure you include the Authorization header with your Pipedream API key for both GET and PUT. - Example: Authorization: Bearer <YOUR_API_KEY> Content-Type: application/json ### 4. Request Body - The PUT endpoint expects a specific payload. If you send an invalid or empty body, it may fail. - According to the Pipedream API docs, you must send a valid JSON object with the fields you want to update. Example: on { "code": "new code here" } ### 5. Source Creation Method - You mentioned you created the source via the trigger API. If you created a prebuilt trigger (from the Pipedream registry), you cannot update its code via the API. Only custom sources (created with your own code) can be updated this way. ### 6. Permissions - Make sure your API key has access to the workspace and source you’re trying to update. — ## Common Causes for “Record is not found” on PUT - Wrong source_id: Double-check for typos. - Source is not a custom source: Only custom sources can be updated via PUT. - Source was deleted: If the source was deleted after creation, GET may be cached, but PUT will fail. - Wrong workspace: If you have multiple workspaces, ensure you’re using the correct API key. — ## What to Do Next - Double-check all the above points. - If you continue to have issues, please provide: - The exact request you’re making (headers and body, with sensitive info redacted) - The full error message and status code If you’re still stuck, please visit Support - Pipedream for more support options. — Summary: The most common cause is trying to update a prebuilt trigger (not a custom source), or a typo in the source_id. Only custom sources can be updated via the API. Double-check your source type and all request details.

can we turn custom sources into triggers, or can we update custom sources with our own webhook url

Let’s address your questions step by step: ### 1. Can we turn custom sources into triggers? Yes. On Pipedream, a custom source is essentially a trigger. When you create a custom event source (using your own code), it emits events that can trigger Pipedream workflows. So, by creating a custom source, you are effectively creating a custom trigger for your workflow. > From the docs: > Event sources run code to collect events from an API, or receive events via webhooks, emitting those events for use on Pipedream. Event sources can function as workflow triggers. ### 2. Can we update custom sources with our own webhook URL? You cannot directly update a custom source to point to a new webhook URL via the API. However, you can edit the code of your custom source to receive webhooks at its unique URL (provided by Pipedream), or to call out to another webhook. - If you want to receive webhooks: When you create a custom source that listens for webhooks, Pipedream assigns it a unique URL. You can configure your external service to send webhooks to this URL. - If you want to forward events to another webhook: You can modify your custom source code to send (POST) the event data to any external webhook URL you specify. #### Example: Forwarding events to your own webhook ```
import { axios } from “@pipedream/platform”; export default defineComponent({ props: { webhookUrl: { type: “string”, label: “Your Webhook URL”, }, }, async run({ steps, $ }) { // Forward the event to your webhook await axios($, { method: “POST”, url: this.webhookUrl, data: steps.trigger.event, // or whatever data you want to send }); return { success: true }; }, });

can you give me the a sample curl command of that to try

Certainly! If you have created a custom webhook source in Pipedream, Pipedream will provide you with a unique webhook URL (let’s call it https://endpoint.m.pipedream.net/abc123). You can send a sample HTTP POST request to this URL using curl like this: bash curl -X POST https://endpoint.m.pipedream.net/abc123 \ -H "Content-Type: application/json" \ -d '{"message": "Hello from curl!", "foo": "bar"}' Replace https://endpoint.m.pipedream.net/abc123 with your actual Pipedream webhook URL. This will send a JSON payload to your Pipedream source, triggering your workflow or custom source code. You can adjust the data in the -d flag as needed for your use case. Let me know if you need an example for a different HTTP method or content type!

when i now try to create a source via the post: https://api.pipedream.com/v1/sources

I get

{
“error”: “please specify a valid workspace”
}

When you see the error: on { "error": "please specify a valid workspace" } when calling POST https://api.pipedream.com/v1/sources, it means your API request is missing the required workspace information. Key points to resolve this: 1. You must specify the workspace in your API request. This is typically done by including a workspace_id in your request body or as a parameter, depending on the endpoint’s requirements. 2. Check your authentication method: According to the Pipedream REST API docs, the “Create a Source” endpoint is only available when using user API keys, not workspace OAuth tokens. Make sure you are using a user API key for authentication. 3. How to find your workspace ID: - You can find your workspace ID in the Pipedream UI, usually in the URL when you are viewing your workspace, or via the API if you list your workspaces. 4. Example request: bash curl -X POST https://api.pipedream.com/v1/sources \ -H "Authorization: Bearer <YOUR_USER_API_KEY>" \ -H "Content-Type: application/json" \ -d '{ "workspace_id": "<YOUR_WORKSPACE_ID>", ...other required fields... }' Replace <YOUR_USER_API_KEY> and <YOUR_WORKSPACE_ID> with your actual values. — If you continue to have trouble, please visit Support - Pipedream for more support options.

is creating sources through this API still supported? can’t seem to get a 200 no matter what I try