I am having trouble using the ScienceDirect API and looking for help.Before I used the API with a requests.get and everything worked just fine.Due to some alternations on my search string I am forced to use the put-method (their API support told me so).
This is my code:
headers = {}headers['Accept']='application/json'headers['X-ELS-APIKey'] = 'my Api code here'headers['X-ELS-Insttoken'] = 'my institutional token here'headers['Content-Type'] = 'application/json'data = {'qs':'("blockchain" OR "distributed ledger" OR "DLT") AND ("circular economy" OR "sustainable supply chain“)','offset': 0} Url = "https://api.elsevier.com/content/search/sciencedirect"r = requests.put(Url, data =json.dumps(data), headers=headers)print(r.url)
I followed the documentation here: https://dev.elsevier.com/documentation/ScienceDirectSearchAPI.wadlWhen I run this code I receive the error message:
{"service-error":{"status":{"statusCode":"AUTHENTICATION_ERROR","statusText":"No APIKey provided for request"}}}
My apiKey
and the institutional token are correct and as I see it submit them in the header.Do you have any idea why this error occurs? Am I submitting the header somehow incorrect?
Best Answer
actually this error happened bc of your website address. on the science direct you have to register your website address to get your Api_key then if you want to test your in your local system it doesn't work.I suggest you:
- start a django or flask project
- set your project on port 8080
- register your website in Sciencedirect like this: https://localhost:8080