1

I just started learning how to use API and I found some really usefull websites and apps like Postman and import.io yet I'm having problems finishing it without help.
I started my little project by getting a working api from import.io (It reads a website and can give you a working API that finds the info in the website)
My REST API looks like this:

https://extraction.import.io/query/runtime/7629f27e-ceee-4ce2-9a1c-cede623d2fc0?_apikey=[apiKey]&url=http%3A%2F%2Fimdb.com

To test and make sure it's working I used postman app and then found a neat feature - code generation.

The app generated this code:

import http.client

conn = http.client.HTTPSConnection("extraction.import.io")

headers = {
'cache-control': "no-cache",
'postman-token': "2087cc79-77b5-0cb9-aa06-adc642978287"
}

conn.request("GET", "/query/runtime/1ac40e3e-f3eb-4290-88c0-e2651b8194a5?_apikey=[apiKey]&url=http%253A%252F%252Fwww.leagueofgraph.com", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))

however the result is:

{
  "message" : "Your extraction request has failed.",
  "code" : 1003
}

What am I doing wrong?

1 Answer 1

2

The code that has been generated has double escaped the "http://"

it should be http%3A%2F%2F not http%253A%252F%252F

Try this corrected code:

import http.client

conn = http.client.HTTPSConnection("extraction.import.io")

headers = {
'cache-control': "no-cache",
'postman-token': "2087cc79-77b5-0cb9-aa06-adc642978287"
}

conn.request("GET", "/query/runtime/1ac40e3e-f3eb-4290-88c0-e2651b8194a5?_apikey=[apiKey]&url=http%3A%2F%2Fwww.leagueofgraph.com", headers=headers)

res = conn.getresponse()
data = res.read()

print(data.decode("utf-8"))
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.