Karate returns HTTP 415 for soap request - testing

I'm trying to hit a SOAP service using karate and it always returns 415, whereas the same service is successful in SOAP UI.
Response in Karate:
20:05:37 20:05:37.236 [ForkJoinPool-1-worker-1] DEBUG com.intuit.karate - response time in milliseconds: 37.15
20:05:37 1 < 415
20:05:37 1 < Content-Length: 0
Given url soapServiceURL
And header Content-Type = 'application/xml'
And request requestPayLoad
When method post
Then status 200
Kindly advise if I'm missing something here

Please read the docs and use soap action if needed: https://github.com/intuit/karate#soap-action
Karate can make any HTTP request, but you need to figure out the right headers etc. One hint is export to cURL and then you will be able to do it easily.

Related

PATCH operation failing in Karate Version 1.2.0. It return HTTP call failed

I am trying to perform patch operation using latest version of Karate with below,
Also I notice the special charater "/" in the payload is replaced by "/" in the report. Hoping that is not a issue as I tried sending the exact payload captured in report through postman and the request went through. Is there a way to avoid replacing that special characters, even after using charset UTF-8 and surefire plugin configuration?
Scenario: Test for PATCH METHOD
Given url URL
And request [{ "op":"replace","path":"/Package/Content/Application/OtherIncome/0/#Frequency","value":"Monthly"}]
And header Content-Type = 'application/json-patch+json; charset=utf-8'
And header Accept = 'application/json'
When method patch
Then status 200
Error:
00:19:07.042 java.lang.RuntimeException: java.io.EOFException, http call failed after 2575 milliseconds for url: https://apigateway.bbldtl.int/babl/int/dev/loan-application-api/v1/applications/22634247
00:19:07.042 classpath:loanApplicationApi/Patch/editIncome/editIncome.feature:15
When method patch
http call failed after 2575 milliseconds for url: https://apigateway.bbldtl.int/babl/int/dev/loan-application-api/v1/applications/22634247
classpath:loanApplicationApi/Patch/editIncome/editIncome.feature:15

Request in Postman with same cookies and headers like in browser returns 401, but in browser all works fine

I trying to scraping data from this url:
https://rgis.mosreg.ru/v3/swagger/map/layer?SERVICE=GeoJSON&layer=34&bbox=37.51027598519073,55.58991,37.84716401480926,55.89414999999997&zoom=11
In web browser, if I visit main page https://rgis.mosreg.ru first (to get cookies), and next - go to this url - all works fine.
But when I trying to perform this request in Postman - its fault with 401 "Unautorized" error.
In Postman I use all same headers and cookies, like in web-browser, but it does not help.
All cookies and headers are synced with browser using Postman INTERCEPTOR
What I missing out?
Chrome screen with headers
Postman screen. Header "mojo" looks line auth header
The server seems to only accept HTTP/2 and reject HTTP/1.1 call. If you have curl compiled with http2 support, you can test this directly:
curl --http2 'https://rgis.mosreg.ru/v3/swagger/map/layer?SERVICE=GeoJSON&layer=34&bbox=37.51027598519073,55.58991,37.84716401480926,55.89414999999997&zoom=11'
Output
< HTTP/2.0 200
< server:nginx/1.19.5 (MOGT Edition # rgis-pub-app-01)
otherwise it returns 401
At the moment, you can't run this request in Postman, because Postman doesn't have http2 support yet
You can also test it with python using the httpx package (pip install httpx[http2]):
import httpx
import asyncio
url = 'https://rgis.mosreg.ru/v3/swagger/map/layer?SERVICE=GeoJSON&layer=34&bbox=37.51027598519073,55.58991,37.84716401480926,55.89414999999997&zoom=11'
r = httpx.get(url)
print(r.http_version)
print(r.status_code)
client = httpx.AsyncClient(http2=True)
async def get():
response = await client.get(url)
print(response.http_version)
print(response.status_code)
asyncio.run(get())
Output
HTTP/1.1
401
HTTP/2
200

How to pass x-www-form-urlencoded - grant_type=client_credentials in Karate

How to pass x-www-form-urlencoded - grant_type=client_credentials in Karate.
Hi,
I am trying to pass value grant_type=client_credentials in the form of x-www-form-urlencoded in karate which i was doing with postman.
i know karate will default set the content type as x-www-form-urlencoded, but can u help what i am doing wrong here?
Karate script:
enter code here
Given url 'http://env/singlesignon/v1/access/token'
And header Authorization = 'Basic c2JsLWFwaWdlZS1lemJvYi1jbGllbnQ6c2JsLWFwaWdlZGllbnQ='
And header X-Correlation-Id = 'alibgefh'
And header X-Consumer = 'APIGEE'
And form field grant_type = 'client_credentials'
When method post
Then status 200
Request headers:
enter code here
Authorization: Basic c2JsLWFwaWdlZS1lemJvYi1jbGllbnQ6c2JsLWFwaWdlZGllbnQ=
Connection: Keep-Alive
Content-Length: 29
Content-Type: application/x-www-form-urlencoded; charset=UTF-8
X-Consumer: APIGEE
X-Correlation-Id: alibgefh
Response:
{"error_description":"Wrong Content Type","error":"Bad Request" }
Maybe your server doesn't like the charset=UTF-8 part (which is a bug on your server). Try adding this line before:
* configure charset = null
Else there is insufficient data in your question. Work with someone in your server-side team if possible. You can try to edit your question with a working cURL command, that might help.

How to Hide Allow: POST, GET, OPTIONS, HEAD and server name in tomcat response

< HTTP/1.1 405 Method Not Allowed
< Allow: POST, GET, OPTIONS, HEAD
< Content-Length: 0
< Date: Fri, 26 May 2017 12:05:36 GMT
< Server: myservername
Hi whenever i do a curl request to my application using HTTP TRACE method . The above response displays .
Can someone tell me the steps to hide the "Allow: POST, GET, OPTIONS, HEAD" and "Server: myservername" information. How to hide these two in my TOMCAT6
By default Tomcat automatically responds to TRACE requests with a status code 405 and the headers you showed.
To change this behaviour you can do the following:
Allow TRACE requests to reach your servlets. This is done by settings the allowTrace attribute to true on a connector: https://tomcat.apache.org/tomcat-5.5-doc/config/http.html#Common_Attributes
In your servlet detect and handle the TRACE request and the send only the headers you want to send.
I think you should not take so much attention about that.
You launched a HTTP request with the method TRACE.
The answer tells you that method TRACE is not supported (Status 405) and provides available and supported method in the header Allow : POST, GET, OPTIONS, HEAD
All of this is perfectly acceptable and seems like a normal behaviour.
About the Server header, you have some details here

Datastore API always returning "dsid: Missing Value" error

I'm trying to follow the datastore API tutorial and this simple request (sent via Fiddler):
POST https://api.dropbox.com/1/datastores/get_or_create_datastore HTTP/1.1
User-Agent: Fiddler
Host: api.dropbox.com
Content-Length: 12
Authorization: Bearer [snipped]
dsid=default
always results in this error response:
HTTP/1.1 400 Bad Request
{"error": {"dsid": "Missing value"}}
The access token was created from the developer app console, and my test app has full dropbox permissions. Running the list_datastores API call succeeds and reports that I do have one datastore with a dsid of default.
I think you'll need a header of Content-Type: application/x-www-form-url-encoded, since you're sending form-encoded parameters.