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

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.

Related

Mule 4: uriParams size is showing as 0 even though it is there

So I created a endpoint inside the raml file such as:
/proxy:
/{proxyDestinationTarget}:
uriParameters:
proxyDestinationTarget:
type: string
example: "myurl.com"
post:
description: Pass through operation that targets IAA
is: [client-credentials-required,standard-error-responses,traceHeaders]
and then inside of the logic.xml in my variable component I have
attributes.uriParams.'proxyDestinationTarget'
when I send the request in postman and debug i am getting a uriParams size of 0
the url i entered in postman is
https://localhost:8092/proxy/uat.something.somethingElse.com/Assign/Assignment.svc
but if i send a request like this :
https://localhost:8092/proxy/uat.something.somethingElse.com
I get a uriParam size = 1 which is what I want. I guess the / is whats causing the problem. how can I pass url as uri param with escape characters???
It looks like you are not sending an URL that matches the RAML definition in the first case.
For the URL:
https://localhost:8092/proxy/uat.something.somethingElse.com/Assign/Assignment.svc
The RAML defined that the API should expect /proxy/{proxyDestinationTarget} but it is receiving something like /proxy/{proxyDestinationTarget}/Assign/Assignment.svc, where {proxyDestinationTarget} is uat.something.somethingElse.com, but nothing matches /Assign/Assignment.svc. The API should include those two last components too to match. It is not escaping them, they probably need to be defined.

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'

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.

How to properly encode special characters in a REST API url

EDIT: The NHTSA docs, as CBroe points out, say to replace an ampersand with an underscore. However, I'm also getting an error with forward slashes (albeit a different one, page not found, because it's decoding the slash), for example the make 'EXISS/SOONER':
http://www.nhtsa.gov/webapi/api/Recalls/vehicle/modelyear/1997/make/EXISS%2FSOONER?format=json
And replacing the ampersand with an underscore no longer results in an error message, but in zero results returned, which should not be the case.
ORIGINAL POST:
I'm trying to download the content from the following URL:
http://www.nhtsa.gov/webapi/api/Recalls/vehicle/modelyear/1997/make/s&s?format=json
And the site returns the following error message:
Server Error in '/' Application.
A potentially dangerous Request.Path value was detected from the client (&).
The problem is the ampersand; a similar request for a different car make works:
http://www.nhtsa.gov/webapi/api/Recalls/vehicle/modelyear/1997/make/toyota?format=json
I have verified from a different endpoint that S&S is a valid make for the API.
Based on stackoverflow answers, I've tried all the following without success:
http://www.nhtsa.gov/webapi/api/Recalls/vehicle/modelyear/1997/make/s%26s?format=json
http://www.nhtsa.gov/webapi/api/Recalls/vehicle/modelyear/1997/make/s%26amp;s?format=json
http://www.nhtsa.gov/webapi/api/Recalls/vehicle/modelyear/1997/make/s%26amp%3Bs?format=json

Android HttpGet Url causes "Illegal Character at Index 110" error

I'm trying to instantiate an HttpGet Object so that I can send a get request to the foursquare api. However, every time I attempt this, (and I've tried it with several different tokens) I get the following error:
java.lang.IllegalArgumentException: Illegal character in query at index 110: https://api.foursquare.com/v2/users/self/checkins?oauth_token=VIHXZZH1ZEXTXOYDFRHHWF42YREWKMNTABDTTVMMF3CSYTKW
It's in the format https://api.foursquare.com/v2/users/self/checkins?oauth_token=OAUTH_TOKEN. You can see my code below. Thanks in advance.
String checkinsUrl = "https://api.foursquare.com/v2/users/self/checkins";
String authUrl = checkinsUrl + "?oauth_token=" + this.token;
HttpGet getMethod = new HttpGet(authUrl);
This was actually just me being stupid. Foursquare sends back a code with is not the access token. You must then make an httpget with that code in order to get the access token.