Illegal Character in Query at Index 40 : when passing double quotes in the header value - urlencode

I have the following URL placed in a property file
mws.add=#['http://kappt.pc.net/LWS/POB/MS.asmx?RK=' ++ vars.RK]
I am passing RK as an header when calling the API ad it is defined as string type in RAML.
when I am passing RK= "abcd" in Postman header, I am getting an error as
Root Exception stack trace:
java.net.URISyntaxException: Illegal character in query at index 40 : http://kappt.pc.net/LWS/POB/MS.asmx?RK="abcd"
How can I encode this URL in property file?

Related

Getting illegal character when sending GET request in JMETER. Working fine in browser

Im getting illegal character in JMETER for GET request -
https://dev1/api/v1/query/job/?filter={%22job_manager_id%22:%22553f2350-12d3-4252-8fe0-39691019c495%22}
tried replacing %22 with "" but still getting illegal character.
Any solutions ?
I think problematic characters are { and }, they need to be percent-encoded
The options are in:
Tick "URL-encode" box next to the filter parameter in the HTTP Request sampler :
Use __urlencode() function in "Path" field like
see Apache JMeter Functions - An Introduction article to learn more about JMeter Functions concept
Or just hard-code the percent-encoded Path part like:
https://dev1/api/v1/query/job/?filter=%7B%22job_manager_id%22%3A%22553f2350-12d3-4252-8fe0-39691019c495%22%7D

Rest call to delete azure storage queue msg with a '+' character in the popreceipt fails

All REST delete calls with a '+' character in the popreceipt fail:
Request URL: https://myaccnt.queue.core.windows.net/myq/messages/mymsg?popreceipt=AgAAAAMAAAAAAAAAW3Dka+IB1gE=
Request Method: DELETE
Status Code: 400 Value for one of the query parameters specified in the request URI is invalid.
BUT
All REST delete calls without a '+' character in the popreceipt succeed:
Request URL: https://myaccnt.queue.core.windows.net/myq/messages/mymsg?popreceipt=AgAAAAMAAAAAAAAA3eUEweIB1gE=
Request Method: DELETE
Status Code: 204 No Content
Since + character is a reserved URL character, you will need to URL encode it. Instead of AgAAAAMAAAAAAAAAW3Dka+IB1gE=, try passing AgAAAAMAAAAAAAAAW3Dka%2BIB1gE%3D in the query string.
When you pass AgAAAAMAAAAAAAAAW3Dka+IB1gE= in the query string, it is received as AgAAAAMAAAAAAAAAW3Dka IB1gE= (+ sign gets converted to a space) and that causes pop receipt to mismatch which results in error.

Call to java script code returning the ASCII encoding for ':' separating key and value of returned object

I making an api request using karate where one of the api request params takes a filter condition (which is a java script object).
I am using a literal notation to create a java script object as shown below. This code is in a separate filter.js file.
function() {
var params = {
val1:[],
val2:[]
};
return params;
}
Now i call the above .js file in the karate scenario as below:
Scenario: Test
Given path 'filtertest/'
* param filter = call read('classpath:feature/common/filter/filter.js')
When method get
Ran the above and when i check the log, the api throws bad request error. I looked at the request url and there i can see that the ':' in the js file where I am assigning a value to a object key is replaced with %3A which i believe is the ASCII encoding for ':'. (the param with its values below)
?filter=%7B%22val1%22%3A%5B%5D%2C%22val2%22%3A%5B%5D
What I want is the ':' to come as it is from the .js call as the server side expects the filter param values as key value pairs.
Is there a way I can achieve this?
If your server cannot decode an encoded : it is a bug: https://www.w3schools.com/tags/ref_urlencode.asp
If you really need this - the workaround is to use the url keyword and build it manually, path and param will always encode.
Given url baseUrl + '/filtertest?filter=foo:bar'

How to set an environment variable from the Response Body in Postman where the concerned keyword is hyphenated

I am trying to set an environment variable by capturing a node from the Response Body of an api, where the node contains two hyphenated words.
My script is - postman.setEnvironmentVariable("Token", jsonData.access-token); - This keeps returning ReferenceError: token is not defined
The node in the Response Body is - {"access-token": "<token>"}
I have tried using this script - postman.setEnvironmentVariable("Token", jsonData.access/-/token/); - This script sets the keyword "Token" as an environment key but does not capture the value of the actual token from the Response Body.
Does anyone know the solution to this problem?
ReferenceError: token is not defined
This indicates that token is expected as a distinct variable, but can't be found.
postman.setEnvironmentVariable("Token", jsonData.access-token);
The above statement has invalid JavaScript syntax, as variable/object property names can't have a hyphen within them. More on valid names here: https://mathiasbynens.be/notes/javascript-identifiers
This can be fixed by using the square bracket notation as follows:
pm.environment.set("Token", jsonData["access-token"]);
Note that the postman.* family of functions is deprecated and has been replaced with their pm.* equivalents. More details can be found here: https://www.getpostman.com/docs/v6/postman/scripts/postman_sandbox_api_reference
I use this code to get token from response and set it in enviroment variable
const responseJson = pm.response.json();
console.log(responseJson);
if(typeof responseJson.access_token !== 'undefined'){
pm.environment.set("gateway-access-token", responseJson.access_token);
}

Invalid client_id when using the linkedin-api-php-client library by zoonman

I'm using this api client library for php and I get the next error all the time when making the first Oauth2 redirection to get the GET(code) first token:
The passed in client_id is invalid
What's happening?
Solved, there was en error while creating the client id string from the .env hidden file. It was generating by adding a return carriage ascii code at the end, due was read by file() php function that by default, includes the EOL characters at the end of each returned array line.