Content-Encoding response header not returned in karate GET call - karate

Actually I was trying to migrate my old test suite to Karate framework.
And I have to validate response headers, In that "Content-Encoding" header is not returned in Karate GET call - I checked it in results I could see all other response headers but not "Content-Encoding" and returns null for assertion.
The same GET call I checked it in chrome browser - developer console and POSTMAN in both the tools I could get "Content-Encoding" but not in Karate.
Please help me in this.

If the server returns Content-Encoding you will see it else you will not.
To validate that a header does NOT exist, it is simple:
And match responseHeaders contains { 'Content-Encoding': '#notpresent' }
Refer responseHeaders: https://github.com/intuit/karate#responseheaders

Unfortunately it does not provide all response headers, because some, like "Content-Encoding: gzip" are stripped away by underlying Apache http libraries after decompressing the content it seems.
See:
Having trouble getting content-encoding to show up in response header for get request

Related

What are the actual request headers sent in the Intellij HTTP client?

IntelliJ has an HTTP client. When composing a file that is interpreted by the HTTP client, you can specify headers that go out to the server with the request, like so:
###
GET https://{{hostname}}/{{path}}
Content-Type: application/json
X-Auth-Token: {{x-token}}
I want to find the actual value of the token that was used to replace the variable name, seen above as {{x-token}}, but I don't see any way to obtain the request headers. The response headers are obviously available, but not the request headers. See the image below for the test results that are shown after running the HTTP client inside Intellij:
Is there a way to display the REQUEST headers?
Link to IntelliJ Documentation - HTTP Client -- the documentation seems to never mention the actual request headers that are sent over the wire, but they do discuss how to define request headers in composing the .http file type.
Check the Tools | HTTP Client | 'Show HHTP Requests History' action.

how to send Content-Length in rest assure ,Since encountering error that "Content-Length header already present"

I am performing post operation using RestAssure and where in header I am passing Content-Length as below -
queryParam().header("Content-Length", "value_Of_It")
and due to that, I am encountering the error that "Content-Length header already present".
it would be great if someone can help me out to resolve it ?
Caused by: org.apache.http.ProtocolException: Content-Length header already present
And below are the headers gets added in postman by default,So while automating in Rest Assure d i need t pass them if not then how to resolve since getting 400 Bad request ? -
Rest-Assured automatically add Content-Length to header when doing the POST request. I've already tested with Postman proxy to see all information in Rest-Assured request.
Code:
given().proxy(5555)
.body("test")
.post("http://postman-echo.com/post");
If I add another Content-Length, I will get the same error as yours.

POSTMAN - unable to fetch all the RESPONSE HEADERS including TOKEN

I am trying to access the token from the Response Header of the POST request. However, when I POST the request in POSTMAN it doesn’t show all the Response headers which I see on the chrome dev tool.
The KEY in the response header I am after is :
location: https://app.rm.dev/auth/callback/?token=
Also, I can see when I POST the request I receive a GET request in the chain in the Console window [image attached]. I tried but was unable to get all the Response Headers, therefore is there a way I can copy the GET request Token value from the Console window shown in the Image?
Found the solution, just needed to toggle off Auto redirect option in Postman Settings.

Same HTTPS request works in Postman but gives 400 Bad Request in JMeter

I think I tried all the possible combinations of headers and body for my POST request in JMeter but is giving me 400 Bad Request saying that the languagePairID parameter from the body is invalid even tho it is exactly same as in Postman.
My headers:
And the request:
Meanwhile in Postman in works perfectly fine:
I tried checking and unchecking the multipart/form-data and browser-compatible headers, but nothing seems to help. I read that using Wireshark might be useful in such cases but I think for this one is not possible as it is HTTPS. I will be very grateful for any advice.
Uncheck "Use mutipart/form-data"
Remove everything from the "Body Data" tab
Switch to "Parameters" tab and put your parameters there:
Going forward be informed that you can easily convert your Postman script into JMeter:
Start JMeter's HTTP(S) Test Script Recorder
Import JMeter's certificate to Postman
Configure Postman to use JMeter as the proxy
Run your request in Postman
JMeter will capture the request and generate relevant HTTP Request sampler and HTTP Header Manager
More information: How to Convert Your Postman API Tests to JMeter for Scaling

REST request doesn't work outside of Explorer

I'm using Restler's API Explorer (a fork of Swagger UI) and when I test a service call there it works fine but when I cut and paste the same URL into Chrome's Advanced REST Client I get a "403 Forbidden" error. How can that be? Is there some sort of required header parameter that needs to be passed with the request?
Here are the screen shots:
You need to get the content type right. Make sure you are sending the data as JSON (application/json)
You need to add a header
Content-Type application/json