Service Domain Created via API gets 404 error
caret-jake
PROOP

2 years ago

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
  }
}

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",
    },
  },

7 Replies

2 years ago

this worked for me -

query -

mutation serviceDomainCreate($input: ServiceDomainCreateInput!) {
  serviceDomainCreate(input: $input) {
    id
    environmentId
    domain
    projectId
    serviceId
    targetPort
    updatedAt
  }
}

variables -

{
  "input": {
    "environmentId": "",
    "serviceId": "",
    "targetPort": 3000
  }
}

caret-jake
PROOP

2 years ago

Will try right now! And that hits the /v2 endpoint?


2 years ago

yep, this is the endpoint i tested with -


caret-jake
PROOP

2 years 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


2 years 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


caret-jake
PROOP

2 years ago

Gotcha okay. Still learning my way around the API but got it all working now. Thank you for the help!


2 years ago

no problem!


Loading...