0

so i was just in the process of check the voters list for my country and i wanted to write a scrite to do, but u am getting this error. Error Fetching http headers

here is my code :

import requests
headers = {'Accept-Encoding': 'gzip, deflate', 'Accept': '*/*', 'User-Agent': 'python-       requests/2.17.3', 'Connection': 'keep-alive'}



url = 'https://ecj.com.jm/wp-content/themes/electorial/inc/voters-list-query.php'


kool = { 'FirstName' : 'john', 'LastName' : 'doe', 'DateOfBirth' : '18/12/1998' }

print('getting ready to send data')
x = requests.post(url, data = kool, headers=headers)
print('data sent.. waiting on response')


print(x.text)

and here is the ajax code i pulled from the website:

 request_url = "https://ecj.com.jm/wp-content/themes/electorial/inc/voters-list-query.php";

        serialized_form = $( this ).serializeArray();
        jsonForm = JSON.stringify( serialized_form );
        form_obj = JSON.parse( jsonForm );

        $.ajax({
            url: request_url,
            method: "POST",
            data: { 'FirstName' : form_obj[0]['value'], 'LastName' : form_obj[1]['value'], 'DateOfBirth' : form_obj[2]['value'] },
            dataType: "json",
            success: function( data ) {
                clearOutput();
                processResponse( data )

1 Answer 1

1

The error is server-side. I guess request is missing Content-Type header. Try adding "Content-Type": "application/json"

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.