Message Boards Message Boards

Accessing "Instant API" From Azure API Manager Blocked?

I created an "Instant API" that I want to run through my Microsoft Azure API Management Portal. I know the tool well and have never run into issues.

My Wolfram API works when visited in a browser directly and when I visit the Azure proxy API directly in a browser as well.

I am not sure if this is related to cross domain scripting blocks or what. It is very strange that it works in a browser but inaccessible from Azure server. I can't find any documentation helpful after searching here, Google and stackoverflow.

Here is my Wolfram API:

https://www.wolframcloud.com/objects/user-68afa30f-88be-452e-ae34-910778a40483/JSON?text=What+is+the+problem%3F

Here is my Azure API:

https://bt.azure-api.net/classifier-beta/api?content=Who+is+this+texting+me%3f&subscription-key=25333e73bf2c4be0865bf9a04a33d44d

Here is the Response headers showing in Azure:

Response status

500 Internal Server Error
Response latency

302 ms
Response headers        
Pragma : no-cache
        Content-Length : 2283
        Cache-Control : no-cache, no-store, must-revalidate, max-age=0
        Content-Type : text/html;charset=UTF-8
        Date : Sun, 21 Sep 2014 01:20:28 GMT
        Expires : Wed, 31 Dec 1969 23:59:59 GMT
        Set-Cookie : WR_SID=172.26.3.22.1411262429386879; path=/; max-age=315360000; domain=.wolframcloud.com,JSESSIONID=57FDB33A4D6E080DB5272443584AA72F; Domain=.wolframcloud.com; Path=/; HttpOnly,AWSELB=C73773D3101BB33071B2BCAF309546EEA98E5E70DB22D4747043839F966280B321CCF09E33C1D504ACBAD308925AF344966D90E498D4407B3BDA361C1537CC799DDE41A89AC1BE9B55A205CE20257C57E904F7A237;PATH=/;DOMAIN=.wolframcloud.com;HTTPONLY
        Server : Microsoft-HTTPAPI/2.0
POSTED BY: David Johnston
10 Replies
Posted 10 years ago

I can confirm that you get a 500 response if no User-Agent header is sent.

We are preparing a fix for this.

POSTED BY: Joel Klein
POSTED BY: David Johnston

You can go here to get 1,000 test queries free.

POSTED BY: David Johnston

Step 1: Create a free test account here

Step 2: Go to API's tab here

Step 3: Select #4 Beta API here

Step 4: Scroll down and click blue button "Open Console"

Step 5: Add a message in the message box

Step 6: Do not enter any headers and then click button "HTTP GET"

Step 7: Review error message returned from wolfram

Step 8: Go back and add this header into the headers box "User-Agent:Mozilla"

Step 9: Click "HTTP GET" again and see that it returns 200 and works fine

POSTED BY: David Johnston
Posted 10 years ago

I get

{ "statusCode": 401, "message": "Access denied due to invalid subscription key. Make sure you are subscribed to an API you are trying to call and provide the right key." }

Where do I access the subscription key? The link to it is broken: https://bt.portal.azure-api.net/%22/developer/%22.

POSTED BY: Joel Klein
Posted 10 years ago

I did find my API key, so now I can play with it. I'm seeing a 500 response when no UserAgent is specified. We should be able to take it from here.

POSTED BY: Joel Klein
Posted 10 years ago

The UserAgent shouldn't matter. We want Instant APIs to be accessed from any user agent imaginable, so, no, we don't block API access on purpose for Azure or anything else.

Chances are there's a different issue at play and the different User-Agent string just happens to coincide.

If you have a sequence of concrete steps we could take to illustrate the problem (particularly how to make the HTTP request that fails), we could debug it.

POSTED BY: Joel Klein

Thanks for the tip. :) I hope they didn't block API access from servers on purpose. I wonder, is there a way to set some permissions in my WL app that allows Azure? I have it set to Public.

POSTED BY: David Johnston

I've discovered that the request User-Agent is rejected if it's not that of standard browser. See if you can change that in Azure.

POSTED BY: Jesse Friedman

You are brilliant! All I did was set user agent as:

User-Agent: Mozilla

and it worked!!! :)

POSTED BY: David Johnston
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract