How to give forward slash in postman url as a parameter - url

This the controller calls having path variable.
#RequestHapping(value="/circuit/getCircuitDetails/{circuitid:.+}", method =RequestMethod.GET, produces "application/json")
public ResponseEntity<ResponsePayLoad> getCircuitDetails (HttpServletRequest request, **#PathVariable (value = "circuitId" String circuitid**) throws Exception {
If I give path variable CircuitId as N1036596/N1036597 in postman url -> that is string containing forward slash
http://localhost:77/enggnar/circuit/getCircuitDetails/N1036596/N1036597
It is giving me error in postman.
Even by giving %2F and %5c in place of slash is also not working for me.
Please help me how to give the pathvariable containing forward slash.

Related

Path parameters being passed as a String with comma not read properly in rest assured

I have a code where I am passing path parameters in the GET request in Rest Assured. But I see the path parameters aren't read properly and I see some gibberish text being read. Actually the String I am passing as path parameter contains a comma in it. Below is my code.
ValidatableResponse response = given().header("Authorization", token).header("Content-type", "application/json")
.when().log().all().pathParam("CalendarId", testCaseBean.getCalendarId().toString())
.queryParam("from", testCaseBean.getStartDate()).queryParam("to", testCaseBean.getEndDate())
.queryParam("monthEnd", testCaseBean.getMonthEndBusinessDay())
.get(EndPoint.GET_CALENDAR_BUSINESS_DAY_INFO_DATE_PARAM).then().log().all();
The path param I am passing is "AUS,EUR" and it is being read as AUS%2CEUR. I am passing this path parameter as test data from the CSV file. Below is the request being formed on the console.
https://portculation-qa.us-east-1.m5435454345.easn.mss.com/master-data/v1/calendars/AUS%2CEUR?from=2022-11-01&to=2022-11-01&monthEnd=false
My expected request URI is https://portculation-qa.us-east-1.m5435454345.easn.mss.com/master-data/v1/calendars/AUS,EUR?from=2022-11-01&to=2022-11-01&monthEnd=false
You can see the only difference in the expected and actual URI is the gibberish path param which isn't read properly. Any solution to tackle this issue?
Try adding this:
.urlEncodingEnabled(false)
RestAssured.given()
.contentType(JSON)
.log()
.all()
.urlEncodingEnabled(false)
or:
RestAssured.urlEncodingEnabled = false;
By default it set to true.

cURL wrap url containing token having forward slashes

I have an URL with token having forward slashes like: https://blahblah/blahblahblah/blah=#server.com/something/somewhere/report/view/51234-5678-9101
Replacing / with %2F or _ doesn't work as it is changing token from the point of view of server. Is there any other way I could smuggle / in the URL?
URL encoding is the solution for this problem: https://unix.stackexchange.com/questions/159253/decoding-url-encoding-percent-encoding

Unable to URL encode { } for object filters in softlayer REST URI

I am calling a Get method through Rest and my URI contains { } for object filters in Softlayer. I have used %7B for { and %7D for }, but I get java.net.URISyntaxException.
The URI also contains # which I have replaced with %40. This is working. I am using http Client to execute my Rest Call. The URI works fine on Postman, both with and without URL Encoding.
Here two way to skip or handle #:
how is '#' handled in the softlayer Rest calls
Another way to skip special characters would be, using "\" at the start from any of these chars, here an example of this:
SoftLayer getUsers by userStatusID
Also, it's necessary to skip {}": (special chars in objectFilters), if you are continue hitting with the exception, would be great if you could provide an example or the exactly code that you are trying, for further assistance
How to get Virtual Guests for a specific datacenter
Here a rest request for dal05 datacenter:
https://api.softlayer.com/rest/v3/SoftLayer_Account/getVirtualGuests?objectMask=mask%5Bid%2Chostname%5D&objectFilter=%7B%22virtualGuests%22%3A%7B%22datacenter%22%3A%7B%22name%22%3A%7B%22operation%22%3A%22dal05%22%7D%7D%7D%7D

400 code error when URL contains % symbol? (NGINX)

How to prevent a server from returning an error 400 code error when the URL contains % symbol using NGINX server?
Nginx configuration for my website:
....
rewrite ^/download/(.+)$ /download.php?id=$1 last;
....
When I tried to get access to this URL:
http://mywebsite.net/download/some-string-100%-for-example
I got this error:
400 Bad Request
With this url :
http://mywebsite.net/download/some-string-%25-for-example
it's work fine !
It's because it needs to be URL encoded first.
This will explain:
http://www.w3schools.com/tags/ref_urlencode.asp
URLs can only be sent over the Internet using the ASCII character-set.
Since URLs often contain characters outside the ASCII set, the URL has to be converted into a valid ASCII format.
URL encoding replaces unsafe ASCII characters with a "%" followed by two hexadecimal digits.
URLs cannot contain spaces. URL encoding normally replaces a space with a plus (+) sign or with %20.
The URL interpreter is confused to see a % without hexadecimals after it.
Why would you think of solving by changing Nginx configuration???
It's impossible to solve from the server side. It's a problem from the client side.
https://headteacherofgreenfield.wordpress.com/2016/03/23/100-celebrations/
In that URL, the title is 100% Celebrations! but the permalink is autogenerated to 100-celebrations. It's because they know putting 100% will cause a URL encode problem.
If even Wordpress doesn't do it your way, then why should you do it?

Google OAuth2 redirect_uri_mismatch when your url contains "&"

I am using the PHP HybridAuth library and integrating oauth2 support, all providers such as Yahoo, MSN and Facebook works, except Google, showing
The redirect URI in the request:
https://www.example.com/auth?action=callback&hauth.done=Google did not match a registered redirect URI.
My redirect url is : https://www.example.com/auth?action=callback&hauth.done=Google, I've added both urls to see if I can workaround for their non sense escape limitation, e.g.
https://www.example.com/auth?action=callback&hauth.done=Google
https://www.example.com/auth?action=callback&hauth.done=Google
Still no luck...Any idea?
just an assumption, try urlencode()'ing the url,
$url = "https://www.example.com/auth?action=callback" . urlencode("&hauth.done=Google");
You need use the PHP urlencode function.
urlencode — URL-encodes string
(PHP 4, PHP 5)
string urlencode ( string $str )
This function is convenient when encoding a string to be used in a query part of a URL, as a convenient way to pass variables to the next page.
Example:
$encoded_url = urlencode("https://www.example.com/auth?action=callback&hauth.done=Google");
More informations:
HTML URL Encoding Reference
http://www.w3schools.com/tags/ref_urlencode.asp
PHP urlencode
http://php.net/manual/en/function.urlencode.php

Resources