• Purchasing a license grants permission to use the software and to get Tech Support. A license purchase doesn't grant customization support.

Getting Invalid API v1 key using POST method, but it's working using GET method.

heavytiger

New Member
I tried GET method first, and it's working pretty well. But when I switch to POST method, I am getting below error:

Code:
{
    "status_code": 400,
    "error": {
        "message": "Invalid API v1 key.",
        "code": 100,
        "context": "Exception"
    },
    "status_txt": "Bad Request"
}

This is GET method:

Code:
curl --location --request GET 'https://example.com/api/1/upload/?key=bPl95An642nMwzdA5hxOqKzk9kRuHVeDT&source=https://dss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1297937920,2807167311&fm=26&gp=0.jpg' \
--header 'Content-Type: application/json' \
--data-raw '{
    "key": "bPl95An642nMwzdA5hxOqKzk9kRuHVeDT",
    "source": "https://dss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1297937920,2807167311&fm=26&gp=0.jpg",
    "format": "json"
}'

This is POST method.

Code:
curl --location --request POST 'https://example.com/api/1/upload/' \
--header 'Content-Type: application/json' \
--data-raw '{
    "key": "bPl95An642nMwzdA5hxOqKzk9kRuHVeDT",
    "source": "https://dss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1297937920,2807167311&fm=26&gp=0.jpg",
    "format": "json"
}'
 

Rodolfo

Chevereto creator
Chevereto Staff
You are wrongly passing the post fields as a JSON. That won't work with API V1, you need this command:

Code:
curl --location --request POST 'https://demo.chevereto.com/api/1/upload' \
--form 'key=XXXXXXXXXXXXX' \
--form 'source=https://dss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1297937920,2807167311&fm=26&gp=0.jpg' \
--form 'format=json'

Note that curl is just an HTTP request, in the case of the demo I need to use this command (because of CloudFlare):

Code:
curl --location --request POST 'https://demo.chevereto.com/api/1/upload' \
--header 'Cookie: __cfduid=XXXXXXXX; PHPSESSID=XXXXXXXXXXXX' \
--form 'key=XXXXXXXXXXXXX' \
--form 'source=https://dss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1297937920,2807167311&fm=26&gp=0.jpg' \
--form 'format=json'

Hope it helps.
 

heavytiger

New Member
You are wrongly passing the post fields as a JSON. That won't work with API V1, you need this command:

Code:
curl --location --request POST 'https://demo.chevereto.com/api/1/upload' \
--form 'key=XXXXXXXXXXXXX' \
--form 'source=https://dss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1297937920,2807167311&fm=26&gp=0.jpg' \
--form 'format=json'

Note that curl is just an HTTP request, in the case of the demo I need to use this command (because of CloudFlare):

Code:
curl --location --request POST 'https://demo.chevereto.com/api/1/upload' \
--header 'Cookie: __cfduid=XXXXXXXX; PHPSESSID=XXXXXXXXXXXX' \
--form 'key=XXXXXXXXXXXXX' \
--form 'source=https://dss1.bdstatic.com/70cFvXSh_Q1YnxGkpoWK1HF6hhy/it/u=1297937920,2807167311&fm=26&gp=0.jpg' \
--form 'format=json'

Hope it helps.
I have tried your command, still getting the same error.
 
Top