David
David

Reputation: 3821

REST API Works in Browser, But Not Client

I am developing a REST API, and have found a very interesting problem.

When I access the resources in a web browser (in my case Chrome), everything works fine. However, when I access the resources using a REST client (Google Chrome plugin, web-based client, and a Java applet), NONE of the variables pass to the API. This happens both with GET and POST methods.

I have absolutely no idea why this would be the case, and it's proving very difficult to test the methods before putting them into production (especially with POST methods).

Please help!

Upvotes: 1

Views: 3923

Answers (3)

Zayne komichi
Zayne komichi

Reputation: 535

Faced the same problem I was returning the fetch function from a different file and loading it up using useEffect, This somehow caused the application not to get information initially ended up writing the fetch request in the same file and running it in useEffect

Upvotes: 0

steve
steve

Reputation: 2008

Do you have control of the API also or is it a third party API? If so, do the params arrive at all or do they arrive empty? What's the error code? - a 403 not authorized (which would make sense if the key doesn't pass) or something else due to missing params.

Try the intermediate step of doing it with CURL form the command line - that'll give you more detail on what's coming back.

Upvotes: 0

Michael Manoochehri
Michael Manoochehri

Reputation: 7877

At first glance it sounds it could be 2 things:

  1. You are not correctly passing API parameters via your client or applet
  2. A problem with authentication or cookie management. Does the API require any type of authorization?
  3. Are you forgetting to set a necessary HTTP header?

Upvotes: 1

Related Questions