-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
Quite obvious code from example does not work:
SslApi(api_client=client).create_ssl_test(website_url='https://example.com', check_rate=86400, alert_at=[1, 2, 3])
To Reproduce
Script:
import os
from statuscake import ApiClient
from statuscake.apis import ( SslApi )
client = ApiClient(
header_name='Authorization',
header_value='Bearer %s' % os.environ['API_TOKEN'],
)
SslApi(api_client=client).create_ssl_test(website_url='https://example.com', check_rate=86400, alert_at=[1, 2, 3])Shows an error:
Traceback (most recent call last):
File "sc.py", line 11, in <module>
SslApi(api_client=client).create_ssl_test(website_url='https://example.com', check_rate=86400, alert_at=[1, 2, 3])
File "/Library/Python/3.10/lib/python/site-packages/statuscake/api/ssl_api.py", line 540, in create_ssl_test
...
statuscake.exceptions.ApiException: (400)
Reason: Bad Request
HTTP response body: {"message":"The provided parameters are invalid. Check the errors output for detailed information.","errors":{"alert_at":["Alert At Invalid","Alert At requires exactly 3 unique, positive integer values"]}}Expected behavior
SSL test should be created,
exactly same values works fine with curl:
$ curl -X POST https://api.statuscake.com/v1/ssl -H "Authorization: Bearer ${API_TOKEN}" -d "website_url=https://www.example.com&check_rate=86400&alert_at[]=1&alert_at[]=2&alert_at[]=3"
{"data":{"new_id":"308943"}}Desktop (please complete the following information):
- OS: masOS 13.3.1
- Python: 3.10.10
- statuscake-py: 1.1.0b1
Additional context
If turn on debug, it is seen that list of alert_at sent to server is improperly serialized (different from curl):
send: b'POST /v1/ssl HTTP/1.1\r\nHost: api.statuscake.com\r\nAccept-Encoding: identity\r\nContent-Length: 73\r\nContent-Type: application/x-www-form-urlencoded\r\nAccept: application/json\r\nAuthorization: Bearer...\r\nUser-Agent: statuscake/python\r\n\r\n'
send: b'website_url=https%3A%2F%2Fexample.com&check_rate=86400&alert_at=1%2C2%2C3'
reply: 'HTTP/1.1 400 Bad Request\r\n'it first converted to string "1,2,3" then url-encoded to "alert_at=1%2C2%2C3" and then sent
instead of sending as &alert_at[]=1&alert_at[]=2&alert_at[]=3
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working