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

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

Related

Karate returns HTTP 415 for soap request

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.

The HTTP header line [group Name: XXX-OR-Migration^XXX-OR-Novation] does not conform to RFC 7230 and has been ignored

Our application was working fine on tomcat 8.5.5. Recently, we have upgraded to tomcat 9.0.31 and the login now fails with the below error
Message: The HTTP header line [group Name: XXX-OR-Migration^XXX-OR-Novation] does not conform to RFC 7230 and has been ignored.
Description: The server cannot or will not process the request due to something that is perceived to be a client error (e.g., malformed request syntax, invalid request message framing, or deceptive request routing).
I have added the below attributes in server.xml under the Connector section and the request still fails:
relaxedPathChars="^:{}[]|""
relaxedQueryChars="[]|{}^:\`"<>""
java.net.URLEncoder
URLEncoder.encode(String, StandardCharsets.UTF_8)
Please escape these characters

Jmeter - How to encode HTTP Sampler response to UTF-8

I'm using HTTP Sampler in Jmeter 3.2 and get result in a way:
Pączek
But when I extract response using JSR223 PostProcessor with prev.getResponseDataAsString() I get in Debug:
P�czek
I already added line:
sampleresult.default.encoding=UTF-8
In jmeter.properties
And:
file.encoding=UTF-8
In system.properties
And also added Content Encoding : UTF-8 in HTTP Sampler and HTTP Header with Content-Type paramter set to application/json; charset=utf-8 and added line:
prev.setDataEncoding("UTF-8");
In Post Processor
But nevertheless the results is the same. Maybe there is some other way to configure that?

UnsupportedMediaTypeException RAML Mule

Requirement -
User will hit an URL and a CSV is downloaded on calling machine.
Implementation
Below is my RAML (1.0) definition
/{format}:
is: [ genericErrorResponsesCompliant ]
get:
description: Get/Download list of all ACTIVE accounts in a given format (CSV/JSON) default is JSON
body:
application/json:
responses:
200:
body:
application/octet-stream:
202:
body:
application/json:
404:
body:
application/json:
example: !include resources/json/example/error/error-resource-not-found-response-example.json
ISSUE:
When request are sent using -
API-Console to invoke the API, a CSV response is seen
postman - I get UnsupportedMediaTypeException in Mule Console
postman (when Content-Type application/json is passed) CSV output is seen in the response section
browser I get the error UnsupportedMediaTypeException
Question
If i do not set the content-type then the API-Kit fails validation and an exception is sent. Is there a way where a default Content-Type is set as application/json and the end-user can access the url from the browser and the csv is downloaded?
I should be able to overcome Exception thrown by API-Kit
If you need any more information let me know, but I am struggling to get this done. Any help will be appreciated.
Exception
Root Exception stack trace:
org.mule.module.apikit.exception.UnsupportedMediaTypeException
at org.mule.module.apikit.HttpRestRequest.handleUnsupportedMediaType(HttpRestRequest.java:306)
at org.mule.module.apikit.HttpRestRequest.negotiateInputRepresentation(HttpRestRequest.java:300)
Environment
Mule 3.8 runtime on Studio version 6.1.1
It's because you have this for the GET request:
get:
description: Get/Download list of all ACTIVE accounts in a given format (CSV/JSON) default is JSON
body:
application/json:
Remove body: application/json there's no need for it on the GET request. It will then allow you invoke the API without a Content-type.
I wish if it worked.
Get the same exception. RAML after #ryan-carter suggestions
/{format}:
is: [ genericErrorResponsesCompliant ]
get:
description: Get list of all ACTIVE accounts for a given country in a given format (CSV/JSON) default is JSON
headers:
Content-Type:
default:
'*/*'
responses:
200:
body:
application/octet-stream:

Sinatra, Rack::Test, and Conditional GET requests

I've got a Sinatra 1.2.0 app that is doing Last-Modified validation caching with Rack::Cache. Things are working great-- I call last_modified in my route body and if the cache has an up-to-date copy, the rest of the execution halts, my app responds to the cache with 304 Not Modified, and the cache serves the cached page without having to generate a new one.
My issue is in trying to write tests for this process. Using Rack::Test and Minitest::Spec, I'm simulating the cache's conditional Get request like so:
header "If-Modified-Since", (Time.now.midnight + 1.hour).httpdate
get "/test-url"
last_response.status.must_equal 304
However, that assertion on the last line fails. The app is still sending a 200 status message. Could I be setting up the request wrong? Does Rack::Test do conditional GET's correctly? Any advice would be appreciated.
I was having a similar problem with the If-None-Match header and ETags. I couldn't get this working either with Rack::Test's header method. But what worked was this:
get '/test-url', {}, {"HTTP_IF_NONE_MATCH" => '"15-xyz"'}
last_response.status.should == 304
So, in your case, try:
get '/test-url', {}, {"HTTP_IF_MODIFIED_SINCE" => (Time.now.midnight + 1.hour).httpdate}
last_response.status.must_equal 304
Credits: This was inspired by how Rack::Test implements follow_redirect!
I would use the header that is sent from the response, that is what the actual HTTP client should be using to generate the next request:
# first time responds with the content
get "/test-url"
last_response.status.must_equal 200
# but includes a header timestamp to be used by the client
last_modified = last_response.headers["Last-Modified"]
last_modified.wont_be_nil
# next time, it just responds with a 304 Not Modified status
get "/test-url", {}, {"HTTP_IF_MODIFIED_SINCE" => last_modified}
last_response.status.must_equal 304