Home > OS >  Trying to make a POST request, works with cURL, get a 403 when using Python requests
Trying to make a POST request, works with cURL, get a 403 when using Python requests

Time:10-26

I'm trying to get some JSON data from this API - Cloudflare 504.

AWS Cloudflare Curl Issues
bypassing CloudFlare 403
How to Fix Error 403 Forbidden on Cloudflare
403 Forbidden cloudflare




██████████████████████████████████████████████████████████████


This is a conversion from you curl.
The Content-Type:application/data is added by default when you send JSON data.
I do not know about your json_data.dump or you putting the JSON in parentheses.

import requests

headers = {
    'accept': 'application/json',
}

json_data = {
    'searchText': '*:*',
    'fq': [
        'totalPtoDays:[1 TO 99999]',
        'appFilingDate:[2005-01-01T00:00:00Z TO 2005-12-31T23:59:59Z]',
    ],
    'fl': '*',
    'mm': '100%',
    'df': 'patentTitle',
    'facet': 'true',
    'sort': 'applId asc',
    'start': '0',
}

response = requests.post('https://ped.uspto.gov/api/queries', headers=headers, json=json_data)
  • Related