Keep getting 404 in API Designer


#1

I’m doing a basic GET request from API Designer. But I keep hitting 404.
If I try from a Browser it works without issue.

I’m using HTTP and I select Anonymous.

Request URL
http://host:port/etc

Status
404

/check:
displayName: Health check
get:
  responses:
    200:
      description: OK

#2

Hi DarVar,

Is your API running locally, or deployed somewhere that is accessible to the broader web?

Thanks!

//Dillon


#3

It is running locally (JAX-RS on WebSphere Liberty).
I can try find a moment to create a reproducible scenario over the coming week or 2 and stick it up on GitHub


#4

Hi,

I’ve added some reproduce steps here:


#5

Hi everybody,

I have exactly the same problem and would love to hear some suggestion how to solve this.

Cheers
Igor


#6

We’ve captured the request coming from API-Designer with fiddler and realised that it was an OPTIONS request. Doesn’t matter what request we define in our .raml document - the only request API-Designer is sending is an OPTIONS request.


#8

If you also have a CORS issue that we had and can neither install your API and the API-Designer in the same domain nor make your API CORS-friendly - the only option you have is to set up a proxy on the maching, your API-Designer is running on.
We used Apache for this purpose with following raml.conf:

#Reverse Proxying all requests from API-Designer
Listen 8080

<VirtualHost *:8080>
 ProxyRequests off
   ProxyPass / http://<uri_of_your_api>:<port>/
   ProxyPassReverse / http://<uri_of_your_api>:<port>/
   Header set Access-Control-Allow-Origin "*"
   Header set Access-Control-Allow-Headers "Origin, X-Requested-With, Content-Type, Accept"
</VirtualHost>

As the baseUri in the API-Designer you have to use the domain name of the host, where API-Designer is running.

Hope it helps.


#9

I’m having a similar problem. I’m running API Designer (and also API Console) on my desktop server
in the same Tomcat instance that my API is running in (tho in different web app contexts, of course).
(I do not have an apache2 web server running, just Tomcat7)

I get 404 errors on all calls, even though the same endpoints (GET / etc) work fine from curl(1) or elsewhere.
Everything is on the same host, same domain, so I’m not sure how it could be a CORS issue.
I do not have any authentication enabled for this sample API (and thus no auth in my app.raml either)
(This is all local only on my intranet, so I can’t post the URLs).

My raml file contains

#%RAML 0.8
---
title: appgen
version: 1
protocols: [ HTTP ]
baseUri: http://myhost.mydomain:1080/test/

API Console shows an HTML error response that includes

HTTP Status 404 - /proxy/http://myhost.mydomain:1080/test/

what is that /proxy/ prefix and where is that coming from?

I set a breakpoint in DispatcherServlet in the Tomcat process where my API is running,
but that breakpoint is never hit. Is there anything else I can check?


#10

Hi David,

Can you clarify where the 404s are happening - just on calls in the console to the actual API?

The proxy call is part of the API Console implementation, allowing users to use the designer to call APIs that don’t support CORS. As that proxy won’t know about your localhost, it makes sense you are getting a 404. You can either implement a proxy locally, or you can disable the proxy using RAML.Settings.proxy = ‘’ using the js console via Chrome developer tools, firebug, etc. You’ll need to re-do that each time when you load the designer, but UI and persistence for proxy settings is on the backlog.

Note that if you disable the proxy, your API MUST implement CORS in order for the Console to successfully call the API.

Hope that helps!


#11

I read more about proxies at API Console|Configuring.The doc was a bit cryptic:

A proxy for Try It can be provided after loading the console JavaScript. For example:

RAML.Settings.proxy = ‘http://www.someproxy.com/somepath/

Given the above, trying a GET to http://www.someapi.com/resource would get

http://www.someproxy.com/somepath/http://www.someapi.com/resource

I eventually found where this was set, in ./index.html (for API Console) and ./scripts/main.js (API Designer).
Since I don’t have a proxy, I just updated this to

 RAML.Settings.proxy = '';

and now my API Console can call my REST service.

Note: I Edited to show where to fix this in both API Console and API Designer


#12

Hello, there,

I got the same problem as igor_kosta met.
Both in API-Designer and API-Console, when I use “Try It” for a “PUT, POST, DELETE” method, the browser always sends an “OPTIONS” request to the server.

Here is one of the request header. As you can see, I am trying a PUT request to the server, but the browser sent an “OPTIONS” request, with no body, along with additional header “Access-Control-Request-Method”, and that header contains the correct method “PUT”.
PS: RAML.Settings.proxy = false;, and baseUri = http://10.1.0.4/api/v0.1

**General**
 Request URL:http://10.1.0.4/api/v0.1/access_rules/4a052e1f-149d-707b-c67a-91e67cb796e7
 Request Method:**OPTIONS**
 Remote Address: 10.1.0.4
**Request Headers**
 Accept:*/*
 Accept-Encoding:gzip, deflate, sdch
 Accept-Language:en-US,en;q=0.8,zh-CN;q=0.6,zh;q=0.4
 Access-Control-Request-Headers:accept, content-type
 Access-Control-Request-Method:**PUT**
 Connection:keep-alive
 Host:10.1.0.4
 Origin:http://10.1.0.10
 Referer:http://10.1.0.10/doc/
 User-Agent:Mozilla/5.0 (Windows NT 6.1; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)  Chrome/49.0.2623.23 Safari/537.36

Response Headers
Status Code:200 OK
Allow:HEAD, GET, OPTIONS, PUT, DELETE
Content-Length:0
Content-Type:text/html; charset=utf-8
Date:Thu, 28 Jan 2016 13:17:11 GMT
Server:Werkzeug/0.11.3 Python/3.4.3


Could anyone tell me how to fix this?
Many thanks,

Eric Zhu

#13

Can you raise that to the API Designer Gtihub repo to make the developer team aware of your problem?