Webhook's using Public API
akhil-naidu
PROOP

2 years ago

Can we create webhook on a particular project using the Public API key?

I tried re-creating my api key but no use, I also create API token for individual project and also no use.

Error Message:

{
  "errors": [
    {
      "message": "Not Authorized",
      "locations": [
        {
          "line": 8,
          "column": 3
        }
      ],
      "path": [
        "webhookCreate"
      ],
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR"
      }
    }
  ],
  "data": null
}

37 Replies

akhil-naidu
PROOP

2 years ago

N/A


akhil-naidu
PROOP

2 years ago

Any update? We really need this to provide our application as SAAS to our end users. Vercel is providing this feature though.


brody
EMPLOYEE

2 years ago

adding webhooks works just fine, you might be trying to use the wrong api key

1252436621635223600


akhil-naidu
PROOP

2 years ago

hey @Brody , I'm created a team and created another project within it and would like to add webhook to it.

All other queries like create project, redploy or template deploy are working with my api but not the webhook, any idea what's getting wrong?

Also, I need to create the API token in my personal account right? I was not able to create any api token in my team workspace


akhil-naidu
PROOP

2 years ago

It is working in personal projects but not in team


brody
EMPLOYEE

2 years ago

you need to create the API token for the team account


akhil-naidu
PROOP

2 years ago

can I know, the URL for it


akhil-naidu
PROOP

2 years ago

I can't find it


akhil-naidu
PROOP

2 years ago

1252462238950883300


brody
EMPLOYEE

2 years ago

select your hobby account and then select the team when creating a token


akhil-naidu
PROOP

2 years ago

when, doing it, I'm getting auth errors


brody
EMPLOYEE

2 years ago

what is your status on the team


brody
EMPLOYEE

2 years ago

you may have to ask the owner to create the API token for you


akhil-naidu
PROOP

2 years ago

I'm the admin


brody
EMPLOYEE

2 years ago

please show me the errors


akhil-naidu
PROOP

2 years ago

sure


akhil-naidu
PROOP

2 years ago

This is the request:

mutation createWebhook {
  railway {
    webhookCreate(input: {projectId: "19f097bd-c834-48f1-b55e-50123c01f982", url: "https://webhook.site/ba79d712-b3b4-4221-a5d5-3acf9ff296f7"}) {
      id
      lastStatus
      projectId
      url
    }
  }
}

This is the response

{
  "data": null,
  "errors": [
    {
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR"
      },
      "locations": [
        {
          "column": 26,
          "line": 1
        }
      ],
      "message": "Not Authorized",
      "path": [
        "webhookCreate"
      ]
    }
  ]
}

Just created a new empty project, and new API token and tested it out


akhil-naidu
PROOP

2 years ago

Even tried creating a project token and used it for creating webhook, but facing the same issue


brody
EMPLOYEE

2 years ago

try using a "No Team" token


akhil-naidu
PROOP

2 years ago

Same, error


brody
EMPLOYEE

2 years ago

i was able to replicate this issue using a team token, if i use a "no team" token i am able to add webhooks to pro projects that im a part of


akhil-naidu
PROOP

2 years ago

Let me create a new token and project and then check with it.


akhil-naidu
PROOP

2 years ago

Nice, I was able to replicate it and create webhook. But don't you think it is not the desired way?


brody
EMPLOYEE

2 years ago

if it works it works 🙂


akhil-naidu
PROOP

2 years ago

Seems like the personal tokens are throwing errors now, but a new error message:

{
    "errors": [
        {
            "message": "Nice try. Psst, we have a bug bounty! See the Discord",
            "locations": [
                {
                    "line": 2,
                    "column": 5
                }
            ],
            "path": [
                "webhookCreate"
            ],
            "extensions": {
                "code": "INTERNAL_SERVER_ERROR"
            }
        }
    ],
    "data": null
}

brody
EMPLOYEE

2 years ago

have you tried using the team token?


akhil-naidu
PROOP

2 years ago

yes, no use


brody
EMPLOYEE

2 years ago

can you add a webhook via the dashboard?


akhil-naidu
PROOP

2 years ago

yes


brody
EMPLOYEE

2 years ago

if you can add a webhook via the dashboard you can do so via the API as well


akhil-naidu
PROOP

2 years ago

But, using the public API, I was not able to create webhook using both the teams API token or the Personal Token.

Am I missing something here, based on our previous conversation, I was able to create webhooks using personal token, but now I was not able to create using them.

Error with team token:

{
  "data": null,
  "errors": [
    {
      "extensions": {
        "code": "INTERNAL_SERVER_ERROR"
      },
      "locations": [
        {
          "column": 26,
          "line": 1
        }
      ],
      "message": "Not Authorized",
      "path": [
        "webhookCreate"
      ]
    }
  ]
}

The error with personal token.

{
    "errors": [
        {
            "message": "Nice try. Psst, we have a bug bounty! See the Discord",
            "locations": [
                {
                    "line": 2,
                    "column": 5
                }
            ],
            "path": [
                "webhookCreate"
            ],
            "extensions": {
                "code": "INTERNAL_SERVER_ERROR"
            }
        }
    ],
    "data": null
}

akhil-naidu
PROOP

2 years ago

no issues, I guess using url to be localhost is getting me the error.


akhil-naidu
PROOP

2 years ago

In order to create webhook with Public API.

  1. use personal token (even though the project is in a team)

  2. the URL, cannot he [http://localhost:3000](http://localhost:3000)


brody
EMPLOYEE

2 years ago

may I ask why you thought localhost would work?


akhil-naidu
PROOP

2 years ago

No our developers used it, for testing purpose via a env variable.


brody
EMPLOYEE

2 years ago

okay


sergiodeiscarvalera
HOBBY

10 months ago

Hi. I have the same error, any update?

```json
mutation {

webhookCreate(input: { projectId: "b614efeb-846a-41a7-9895-e437d0c4d38d", url: "https://.../webhook/railway_status_change" }) {

filters

id

lastStatus

projectId

url

}

}
```

```json
{

"errors": [

{

"message": "Not Authorized",

"locations": [

{

"line": 57,

"column": 3

}

],

"path": [

"webhookCreate"

],

"extensions": {

"code": "INTERNAL_SERVER_ERROR"

},

"traceId": "274704726056642564"

}

],

"data": null

}
```

It is not a matter of the API Key, with that same API Key I have created projects, launched services etc...


Loading...