cancel
Showing results for 
Search instead for 
Did you mean: 

Head's Up! These forums are read-only. All users and content have migrated. Please join us at community.neo4j.com.

Authorization difficulty with apoc.load.jsonParams and Microsoft Bing news search API

Hi,

I'm trying to pull in news summaries from Microsoft Bing using the news search API, and have keys for the service. I've tested the keys work using a Jupyter notebook Microsoft provides. I want to pull news into a graph however and have tried the following Cypher as a test:

CALL apoc.load.jsonParams("https://api.cognitive.microsoft.com/bing/v7.0/news/search?q=Neo4j", {Authorization : "Ocp-Apim-Subscription-Key : xxxMyKeyxxx"}, null) YIELD value

Unfortunately this returns an error ('401') which corresponds to an invalid key.

I know the key is valid because it runs through the Jupyter notebook so I suspect the error is related to the format of the header { } I am sending through. Can anybody point me to how this should be correctly formatted?

Similar to the above can anyone point me to the formatting requirements for the payload section of the call (which is NULL in the above examples)?

Many thanks,

Michael

1 REPLY 1

Ok, I have worked out the authorisation of this one. The issue was caused by the dash character in the name of of the authorization key. When there are special characters like this they need to be enclosed in backticks, so the header would look like:
{Ocp-Apim-Subscription-Key : 'xxxMyKeyxxx'}

I had thought it was a key:value pair for the header and had tried so many versions including the mutant version in my original question, however the errors I was getting were a result of not using those backticks.

Hope that helps someone,

Michael

Nodes 2022
Nodes
NODES 2022, Neo4j Online Education Summit

All the sessions of the conference are now available online