token

betbotsdHOBBY

3 months ago

I can't get responses from the api through the generated token. I receive the following error message. What is happening?
project_ID: 80725e53-dbb4-42f3-8ceb-3e05d0864e17

Solved

0 Replies

3 months ago

I will need much more detail to help. What framework/language is the api? How are you accessing it? What URL are you using to access it?


betbotsdHOBBY

3 months ago

ok, the api I'm trying to access is RAILWAY's own through a personal token that I generated on the RAILWAY website.URL: https://backboard.railway.com/graphql/v2
project_ID: 80725e53-dbb4-42f3-8ceb-3e05d0864e17
Linguage: Java Script


betbotsdHOBBY

3 months ago

because the site's documentation tells me to use this url. I followed how it is taught.



3 months ago

still gonna need more information, please provide the mutation and variables you are trying to use, are you trying to use a project or account token?


betbotsdHOBBY

3 months ago

Friend, look, I have a project running on RAILWAY and connected to GITHUB, where all the code is. So I need my RAILWAY project to be restarted from time to time to update the data. Then I saw that this would be possible, using GitHub Actions, creating a workflow using yml. Here is the yml condition in the workflow:

name: Run Script Multiple Times Daily

on:
workflow_dispatch: # Permite executar manualmente
schedule:
- cron: '31 2 * * *' # 05:31 BRT
- cron: '31 7 * * *' # 10:31 BRT
- cron: '31 8 * * *' # 11:31 BRT
- cron: '31 9 * * *' # 12:31 BRT
- cron: '1 11 * * *' # 14:01 BRT
- cron: '1 14 * * *' # 17:01 BRT
- cron: '31 17 * * *' # 20:31 BRT

jobs:
build:
runs-on: ubuntu-22.04 # Ambiente do GitHub Actions

steps:
- name: Checkout code
  uses: actions/checkout@v3

- name: Set up Python
  uses: actions/setup-python@v3
  with:
    python-version: '3.x'

- name: Install dependencies
  run: |
    pip install -r requirements.txt

- name: Run Script
  env:
    SPREADSHEET_ID: ${{ secrets.SPREADSHEET_ID }}
    CREDENTIALS_JSON: ${{ secrets.CREDENTIALS_JSON }}
  run: python atualizar_[planilha.py](planilha.py)

- name: Restart Railway Service
  env:
    RAILWAY_API_TOKEN: ${{ secrets.RAILWAY_API_TOKEN }}
    RAILWAY_SERVICE_ID: ${{ secrets.RAILWAY_SERVICE_ID }}
  run: |
    curl -X POST [https://backboard.railway.app/graphql/v2](https://backboard.railway.app/graphql/v2) \
    -H "Content-Type: application/json" \
    -H "Authorization: Bearer $RAILWAY_API_TOKEN" \
    -d '{"query": "mutation { restartService(id: \"$RAILWAY_SERVICE_ID\") }"}'

It turns out that this request to the RAILWAY API does not return my project and therefore it is not possible to restart it.


betbotsdHOBBY

3 months ago

I've already done the test manually using POSTMAN and it doesn't really return anything, just the error in the photo I sent initially.


3 months ago

please just use this -

it does exactly what you want.


betbotsdHOBBY

3 months ago

ok friend, thank you very much. I followed all the steps, I hope it works correctly. a hug


3 months ago

awesome, let me know if there are any issues


betbotsdHOBBY

3 months ago

Unfortunately there was a problem, I set it to restart every 1 hour and 10 minutes, that is, every 70 minutes and 77 minutes have passed and it has not restarted. What could have happened?


3 months ago

what cron expression did you use?


betbotsdHOBBY

3 months ago

serviceID=f9cb1540-4a60-4003-96f0-cddb96db4db8&projectID=80725e53-dbb4-42f3-8ceb-3e05d0864e17&environmentID=1b1f4f99-aef9-4d4c-9a4d-d1c1840e0cd8&action=restart&expression=15 */1 * * *


betbotsdHOBBY

3 months ago

15 /1**


betbotsdHOBBY

3 months ago

15 /1**


betbotsdHOBBY

3 months ago

I generated the token on the home screen in the account settings and not in the project settings.


3 months ago

what do the logs of the cron service say?


betbotsdHOBBY

3 months ago

Friend, I'm just here to let you know that everything went well, it's working perfectly. I believe that when I sent the message above, the time required for the service to be restarted had not yet been completed. But after a few hours, I went to check the logs and everything is fine. Thanks again for the help.


3 months ago

awesome! and remember, you can add as many schedules you'd like to the cron service!


betbotsdHOBBY

3 months ago

Yes, thank you. Yes, I remember.


3 months ago

!s


Status changed to Solved brody 3 months ago


token - Railway Help Station