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

(Michael Aikenhead) #1

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

0 Likes

(Michael Aikenhead) #2

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

0 Likes