Difference in the HTTP Response code is getting observed when executing a POST call from cURL vs Postman for the same negative test condition - rest

Correct URI: https://example.com/a/b/users/111/c
Negative test URI: https://example.com/a/b/users/<111>/c
Sample Request Body:
{
"abc": "xyz"
}
Postman returned 404 with a message that the user doesn't exist, for the negative test URI mentioned above.
Then I executed the cURL generated by the Postman and appended to it "-k" to ignore the certificate verification and "-v" for verbosity. However, cURL returned 500 for the same URI.
The original concern was that there has been a mismatch in the test results when the above API was hit by an automation test using RestAssured vs when manually executing it from Postman. Debugging that has led me to find out the difference in response between Postman and curl as well.
Any thoughts to debug this issue further?

While debugging, I found the URI passed was getting encoded and decoded, and <111> got printed as %3C111%3E at one of the breakpoints. So when I tried sending the encoded URI from cURL like https://example.com/a/b/users/%3C111%3E/c it worked just fine returning 404. However Postman returned 404 both with <111> and %3C111%3E.
Thanks to #derpirscher for providing hints that helped me reach this conclusion.
P.S. For more details, please refer my last comment above.

Related

Email/Password Authentication Mongodb-stitch Android API

This seems to be on a very new topic because the "stitch" or "mongodb-stitch" tags do not exist yet.
I have a mongodb altas cluster on cloud.mongodb.com. The page https://docs.mongodb.com/stitch/auth/email-auth/ only teaches how to do things with JS but I don't have server side JS on hand. Instead I tried to figure out how to do things with the StitchClient on the Android API.
I was able to register an email/password pair using StitchClient.register(email,pwd) and got an email from no-reply+stitch#mongodb.com with the token/tokenId. I copied them and used StitchClient.emailConfirm(token, tokenId) but failed. The error was:
Unexpected response code 404 for https://stitch.mongodb.com/api/client/v1.0/app/APP-ID/auth/local/userpass/confirm
which sounds strange! I opened a browser and paste that in the URL and got 404 too. I even did
curl --data "token=432...345&tokenId=435..334" https://stitch.mongodb.com/api/client/v1.0/app/APP-ID/auth/local/userpass/confirm
and still got 404.
Is this a bug or an outage of the stitch.mongodb.com server?

Sending HTTP POST to Kitura works wrong on Bluemix

I created a simple REST on Kitura. When I run it on your Mac, it works fine. GET / POST / PUT / DELETE are executed. When I run it on bluemix, GET method works correctly, but the POST is wrong. In response to the POST I should return JSON to create an object and returns a response with the text "unknown" in the body. Then, at my request any returns "unknown". No errors in the logs there. What could it be?
Kitura version 0.15.6, swift-DEVELOPMENT-SNAPSHOT-2016-05-03-a
This was a bug in the Linux implementation of SwiftyJSON that incorrectly marked UInts as invalid.
I fixed this and pushed a new version: 7.0.4
This will now work once you update your dependencies.

How to use JSON in OrientDB HTTP command request

I'm using orientdb-community-2.2-alpha and I'm trying to use JSON payloads with the HTTP command API (as in calling http://<host>:<port>/command/<database>/sql) and I simply can't figure out how to do it. All I get is an OCommandExecutorNotFoundException saying Cannot find a command executor for the command request: sql.<whatever JSON I tried here> no matter what I try.
I'm not providing an example of what I've tried as I'm not trying to do any one specific thing; I would just like to see a working curl example of how to post a generic command request using a JSON payload.
I can use JSON with batch requests just fine, it's just the command API that I can't get to work.
You can try with Postman plugin

Fitnesse scripts failing when expecting HTTP status code 204 from REST service using Jersey

I am facing an issue while writing fitnesse script to test the response from REST service with error code 204 (No content).
I get the below error while doing so.
__EXCEPTION__:com.sun.jersey.api.client.UniformInterfaceException: POST http://localhost/sample/test returned a response status of 204
at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:527) [jersey-client-1.4.jar:1.4]
at com.sun.jersey.api.client.ClientResponse.getEntity(ClientResponse.java:505) [jersey-client-1.4.jar:1.4]
It seems like the service returns 204 (which is correct) and I expect the same in fitnesse script. Still it gives the exception.
Has anyone faced this kind of issue? If so, do you have any solution for the same?

wget returns only (an expected) "401 unauthorized" but no html

In using a browser to test our website, I enter a purposefully incorrect username/password, and get an html page back from the application telling me the login has failed and to "Please check my username & password, then try again". Viewing the source for this page, I can't find a "401" embedded anywhere.
But mimicking the above using wget:
wget http://servername:8011/ui/login.do --post-data="loginId=NotAUser&password=NotAPassword" -U Mozilla -o log.txt
the output file contains "401 Unauthorized", but none of the html mentioned above.
Is there a way to get the html page I was expecting, and just check for the 401 return code with a "$?" test?
The "401 Unauthorised" you're getting is in the headers of the response from the server. A 401 response doesn't have an HTML - it's just an error code.
The page that you describe in the browser is actually generated by the browser, not sent back from the server. Browser vendors generate meaningful error pages rather than just displaying "401 Unauthorized" or "404 Page Not Found" to the user. There's no way to get the HTML code you're seeing using wget because it's not part of the HTTP conversation.
wget used to stop on a non-200 response code and not retrieve the body of the reply. It has been updated to correct this behaviour and versions 1.14-1 and later should work as expected:
http://bugs.debian.org/cgi-bin/bugreport.cgi?bug=247985
If you're stuck with an older version or can't get it to work, why not try curl instead?
https://superuser.com/questions/253826/how-to-use-wget-to-download-http-error-pages