Python requests.post works on my local machine and doesn't on railway

prawwtocolTRIAL

a year ago

versions of python and requests library are same.
code i'm using:

        auth_header = f"api-key {config.HEIGHT_SECRET_KEY}"
        response = requests.post(
            url="https://api.height.app/tasks",
            headers={
                "Authorization": auth_header,
                "Content-Type": "application/json",
            },
            data=json.dumps(
                {
                    "name": task_name,
                    "listIds": [f"{config.HEIGHT_LIST_ID}"],
                }
            ),
        )

which is in accordance to the documentation of Height.app

all config variables are loaded correctly into Railway (checked with logs)

the error I get is that the header vaule auth_header (strangely, a byte string, b"") is incorrect

5 Replies

prawwtocolTRIAL

a year ago

This is how the eror looks like in railway

Attachments


a year ago

I see a new line character on the end of that header value in the screenshot, could that pose an issue?


prawwtocolTRIAL

a year ago

Indeed. I tried doing some weird config.HEIGHT_SECRET_KEY.replace("\n", "") magic with it, but it didn't work. turns out I had a new line in the environment variable section, here on railway.

Thank you for the quick answer. I really really appreciate it.


a year ago

Might be a rhetorical question but you did replace auth_header with your API key right?


a year ago

Could you also link us to the height.app documentation for this, I can't seem to find it myself.