How to solve [Error 414 Response] when inputing long query string into GET function?

Viewed 35

I'm working with a Restful API and I'm feeding a long list (>2000 characters) into the GET function and it's returning a Error 404 Response. I understand that the URI is too long and was wondering what the best way of retrieving all data in the list instead of repeating the GET function multiple times for chunks of the string. I am aware of the POST function however was unsure how to apply it.

API documentation can be found here https://docs.skinport.com/

# The string input is comma delimited i.e '1st Lieutenant Farlow | SWAT,2020 RMR Challengers'

def api_request():
    
    data_packet = \
        requests.get('https://api.skinport.com/v1/sales/history',
                     params={'app_id': 730, 'currency': 'AUD',
                     'market_hash_name': ('{item_list}').format(item_list = string_format)
                     }).json
        
    return(data_packet)
1 Answers

According to your API docs, you want to use a GET request, not POST.

So just switching requests.post to requests.get should solve your problem :)

Related