Service Domain Created via API gets 404 error

Howdy, I'm trying to create a service domain via the API. The API call succeeds, and returns the domain URL but when that URL is accessed it just gets a 404 error. The dashboard also displays the service domain URL correctly. When I create the service domain URL via the dashboard it works as expected. Can you provide any guidance on if my mutation is incorrect or I'm using this wrong? API Mutation:
mutation CreateServiceDomain {
serviceDomainCreate(input: {environmentId: "${environmentId}", serviceId: "${serviceId}", targetPort: ${targetPort}}) {
id
environmentId
domain
projectId
serviceId
targetPort
updatedAt
}
}
mutation CreateServiceDomain {
serviceDomainCreate(input: {environmentId: "${environmentId}", serviceId: "${serviceId}", targetPort: ${targetPort}}) {
id
environmentId
domain
projectId
serviceId
targetPort
updatedAt
}
}
Output:
{
data: {
serviceDomainCreate: {
id: "de660a64-f075-4094-acaa-76457e7dc21d",
environmentId: "48a59fba-0c3b-402b-a145-301c086bd0bd",
domain: "false-piranha-production.up.railway.app",
projectId: null,
serviceId: "9f2edc68-0ed8-405e-9c91-caafe88bf052",
targetPort: 3000,
updatedAt: "2024-07-30T18:19:25.567Z",
},
},
{
data: {
serviceDomainCreate: {
id: "de660a64-f075-4094-acaa-76457e7dc21d",
environmentId: "48a59fba-0c3b-402b-a145-301c086bd0bd",
domain: "false-piranha-production.up.railway.app",
projectId: null,
serviceId: "9f2edc68-0ed8-405e-9c91-caafe88bf052",
targetPort: 3000,
updatedAt: "2024-07-30T18:19:25.567Z",
},
},
8 Replies
Percy
Percy4mo ago
Project ID: de660a64-f075-4094-acaa-76457e7dc21d,48a59fba-0c3b-402b-a145-301c086bd0bd,9f2edc68-0ed8-405e-9c91-caafe88bf052
Brody
Brody4mo ago
this worked for me - query -
mutation serviceDomainCreate($input: ServiceDomainCreateInput!) {
serviceDomainCreate(input: $input) {
id
environmentId
domain
projectId
serviceId
targetPort
updatedAt
}
}
mutation serviceDomainCreate($input: ServiceDomainCreateInput!) {
serviceDomainCreate(input: $input) {
id
environmentId
domain
projectId
serviceId
targetPort
updatedAt
}
}
variables -
{
"input": {
"environmentId": "",
"serviceId": "",
"targetPort": 3000
}
}
{
"input": {
"environmentId": "",
"serviceId": "",
"targetPort": 3000
}
}
Jake Colling
Jake CollingOP4mo ago
Will try right now! And that hits the /v2 endpoint?
Brody
Brody4mo ago
yep, this is the endpoint i tested with - https://docs.railway.app/reference/public-api#endpoint
Jake Colling
Jake CollingOP4mo ago
Thanks for the help I got it working now! Weirdly the answer was to remove the target port? I think because I have it set in the variables already it was causing some sort of conflict when trying to set it here
Brody
Brody4mo ago
that shouldnt cause any conflicts, but if you know your app is listening on PORT already you dont need to specify a target port
Jake Colling
Jake CollingOP4mo ago
Gotcha okay. Still learning my way around the API but got it all working now. Thank you for the help!
Brody
Brody4mo ago
no problem!
Want results from more Discord servers?
Add your server