0

Sorry if this is a duplicate question but google isn't smart enough to understand me or I'm too dumb to express my question simple enough for it to understand.

I don't know if this is my problem but I'm 90% sure this is it. I'd like to know how to represent a Unix path within a GET request so that my web service doesn't return a 404. I think it's because one of my JSON fields in the query is a Unix path and because of the slashes, the webservice thinks it's part of the URL and not a part of my query.

For example, I'm using a RESTClient that's an add-on to Mozilla to test my web service. For the POST request, I enter as the url

http://mytestserver:8080/mydir/

and in the body, I put in my JSON object

{"filename":"obit.jpg", "Path":"test/2/1"}

This method works fine. I get a status code 200 and a return JSON object with the expected output.

When I use the same string for a GET request, I get a status code 404 and no return JSON object. I put as the url in the RESTClient

http://mytestserver:8080/mydir/{"filename":"obit.jpg", "Path":"test/2/1"}

and I get a status code 404 and the response body just says 404 - Not found

To further test my theory, I entered the following url in a GET request, removing the /2/1 from the path, which works.

http://mytestserver:8080/mydir/{"filename":"obit.jpg", "Path":"test"}

I've tried encapsulating the whole JSON string in quotes but that didn't work either so I've run out of things to try.

Thanks in advance for any help you can give me. If I need to show some code, please let me know, although, I don't think it's a code problem, I think it's a representation problem. Thanks.

Classified
  • 5,759
  • 18
  • 68
  • 99
  • Now I feel stupid. Just found this on the related bar on the right. I'll try this out. Thanks for looking. Sorry for wasting your click. http://stackoverflow.com/questions/2992231/slashes-in-url-variables – Classified Dec 13 '12 at 01:51

1 Answers1

0

Found out that JSON objects are usually sent via POST, not GET. Since I appended it to the URL via GET, it gave me problems. Per How to send a GET request with a "/" in the query

Community
  • 1
  • 1
Classified
  • 5,759
  • 18
  • 68
  • 99