Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

'error': 'Invalid L1 Request headers' #92

Open
ben0x01 opened this issue Aug 29, 2024 · 4 comments
Open

'error': 'Invalid L1 Request headers' #92

ben0x01 opened this issue Aug 29, 2024 · 4 comments

Comments

@ben0x01
Copy link

ben0x01 commented Aug 29, 2024

Overview

Try to use the basic script to make orders

Description

I want to make order butgot error Invalid L1 Request headers. I make som orders with web and all is okay

`import os
from py_clob_client.constants import POLYGON
from py_clob_client.client import ClobClient
from py_clob_client.clob_types import OrderArgs
from py_clob_client.order_builder.constants import BUY
from dotenv import load_dotenv

load_dotenv(dotenv_path='.env')

host = "https://clob.polymarket.com"
key = os.getenv("PK1")
print(key)
chain_id = POLYGON

Create CLOB client and get/set API credentials

client = ClobClient(host, key=key, chain_id=chain_id)
client.set_api_creds(client.create_or_derive_api_creds())

resp = client.create_and_post_order(OrderArgs(
price=0.50,
size=100.0,
side=BUY,
token_id="71321045679252212594626385532706912750332728571942532289631379312455583992563"
))

print(resp)`

Notes

`Traceback (most recent call last):
File "C:\Users\user\PycharmProjects\polymarket.venv\lib\site-packages\py_clob_client\client.py", line 218, in create_or_derive_api_creds
return self.create_api_key(nonce)
File "C:\Users\user\PycharmProjects\polymarket.venv\lib\site-packages\py_clob_client\client.py", line 180, in create_api_key
creds_raw = post(endpoint, headers=headers)
File "C:\Users\user\PycharmProjects\polymarket.venv\lib\site-packages\py_clob_client\http_helpers\helpers.py", line 54, in post
return request(endpoint, POST, headers, data)
File "C:\Users\user\PycharmProjects\polymarket.venv\lib\site-packages\py_clob_client\http_helpers\helpers.py", line 42, in request
raise PolyApiException(resp)
py_clob_client.exceptions.PolyApiException: PolyApiException[status_code=401, error_message={'error': 'Invalid L1 Request headers'}]

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\Users\user\PycharmProjects\polymarket\test.py", line 17, in
client.set_api_creds(client.create_or_derive_api_creds())
File "C:\Users\user\PycharmProjects\polymarket.venv\lib\site-packages\py_clob_client\client.py", line 220, in create_or_derive_api_creds
return self.derive_api_key(nonce)
File "C:\Users\user\PycharmProjects\polymarket.venv\lib\site-packages\py_clob_client\client.py", line 201, in derive_api_key
creds_raw = get(endpoint, headers=headers)
File "C:\Users\user\PycharmProjects\polymarket.venv\lib\site-packages\py_clob_client\http_helpers\helpers.py", line 58, in get
return request(endpoint, GET, headers, data)
File "C:\Users\user\PycharmProjects\polymarket.venv\lib\site-packages\py_clob_client\http_helpers\helpers.py", line 42, in request
raise PolyApiException(resp)
py_clob_client.exceptions.PolyApiException: PolyApiException[status_code=401, error_message={'error': 'Invalid L1 Request headers'}]
`

@ben0x01
Copy link
Author

ben0x01 commented Aug 29, 2024

I forgot to delete the "#" before the comment Create CLOB client and get/set API credentials)

@ben0x01 ben0x01 changed the title 'error': 'Invalid L1 Request headers'} 'error': 'Invalid L1 Request headers' Aug 29, 2024
@DanielOllivier
Copy link

Hallo, I'm facing same issue, do you could resolve it ?

@eliiik
Copy link

eliiik commented Dec 17, 2024

Hallo, I'm facing same issue, too. do you could resolve it ?

@ben0x01
Copy link
Author

ben0x01 commented Dec 18, 2024

Hi, check all approves only that can help it)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@eliiik @DanielOllivier @ben0x01 and others