Facing problems with your weatherapi proxy on Apigee ?

3 4 3,994

UPDATE: We published a new proxy in our samples repo: https://github.com/apigee/api-platform-samples/tree/master/default-proxies/helloworld

This is a simple "hello world" proxy that would get you started with the Apigee API Management platform and api proxies.

If you have an account on Apigee Edge, you might have noticed that your weatherapi apiproxy would have started throwing 401 Unauthorized responses in the last few days. If you are facing this issue and need to know what happened to your proxy, here's the answer:

Step 1. Go to your weatherapi proxy on the UI. Go to Trace tab and start a new trace session
Step 2. Make an api call to your proxy:
curl -x http://{org}-{env}.apigee.net/v1/weather/forecastrss?w=12797282 
(Please note that for some of you the basepath may be v0 instead of v1)
Step 3. In the traceUI on the incoming request, select the flow enforcement point which says "Request sent to target server" and observe the target url that the request was sent to. You should see GET http://weather.yahooapis.com/forecastrss?w=12797282
Step 4. Now go to the response flow and select the point which says "Response received from target server". You will see a 401 Unauthorized response from the target. 
Step 5. Scroll down to see the response content. It would be something like this:
<?xml version="1.0" encoding="UTF-8" standalone="yes"?><yahoo:error xmlns:yahoo="http://www.yahooapis.com/v1/base.rng" xml:lang="en-US" yahoo:uri="http://yahoo.com"><yahoo:description>Please provide valid credentials. OAuth oauth_problem="OST_OAUTH_PARAMETER_ABSENT_ERROR", realm="yahooapis.com"</yahoo:description><yahoo:detail>Please provide valid credentials. OAuth oauth_problem="OST_OAUTH_PARAMETER_ABSENT_ERROR", realm="yahooapis.com"</yahoo:detail></yah.....
Please refer to the attached screenshot depicting the same issue.

2240-yahooweatherapi.png

So here's what actually happened. As of Mar 15, 2016 the public version of the Yahoo Weather API aka http://weather.yahooapis.com/forecastrss has been taken off. It now requires an OAuth1.0 token in order to call that api which is why you get the above error. You can follow the blog post here or checkout the Yahoo Weather API homepage (which also seems to have been changed recently). I will go ahead and log a request with our engineering team to remove the yahoo weather api endpoint from our sample proxies. But for your existing proxies, you might want to change the target endpoint from http://weather.yahooapis.com to something which is publicly available like http://httpbin.org.

Here's how to do it and make sure your api is up and running again:

Step 1. Open your weatherapi in the proxy editor in Edge UI. Select the develop tab. 
Step 2. Go to the Target Endpoints section in the Navigator panel on the left. Selec the node called "default".
Step 3. Go to the proxy editor in "xml/code" view and comment/update the <URL> element with the new target endpoint that you want. The below screenshot illustrates this step.
Step 4. Click Save. Make sure your proxy is deployed.
Step 5. Now make an api call. The call would be slightly modified now:
curl -v http://{org}-{env}.apigee.net/v1/weather/ip
Or
curl -v -X POST http://{org}-{env}.apigee.net/v1/weather/post -d 'id=test'
The response would obviously be different because its a totally different endpoint. For the first call your response would be something like:
HTTP/1.1 200 OK
Access-Control-Allow-Credentials: trueAccess-Control-Allow-Origin: *
Content-Type: application/json
Date: Fri, 25 Mar 2016 03:18:07 GMT
Server: nginx
Content-Length: 46
Connection: keep-alive
{
  "origin": "50.XXX.XXX.XX, 54.XX.XXX.XX"
}

2241-edittargetendpoint.png

So there you go. Your proxy would start working again. It would be dumb to call it the weatherapi any more because its not fetching weather information anymore, but you get the point. You can also use other free api endpoints that are available as public APIs. Here's a list of top ten weather APIs, but I am not sure which one of these are free. Keep exploring the API world. Thanks for using Apigee.

Comments
mytre4411
Participant IV

Can APIGEE provide some open API for free just for people like us who are learning APIGEE?So,instead of other public APIs like yahooweather ,we can start using APIGEE provided APIs.So,like the above said problem with yahooapis will not occur.

willwitman
Staff

@Subbu R -- The Apigee doc team is about to publish a complete API sample called StreetCarts. If you're just learning Apigee Edge, you will be able to set up and deploy StreetCarts on Apigee Edge and call APIs that do get, post, put, and delete requests to a backend data store. We'll announce more details about the StreetCarts project soon.

adas
Participant V

@Subbu R In the interim you can use http://httpbin.org

We are also planning to provide our own API endpoint that can be used as target for use-cases like this. We will publish more details once its ready and available.

adas
Participant V

We published a new proxy in our samples repo: https://github.com/apigee/api-platform-samples/tree/master/default-proxies/helloworld

This is a simple "hello world" proxy that would get you started with the Apigee API Management platform and api proxies.

Version history
Last update:
‎03-24-2016 08:24 PM
Updated by: