Postman request not sending "+", "#" keywords to Web api - search

I have created a web api with search option. For checking the api, i have used Postman tool in that i have provided symbols like "+", "#" for search. It is not recognized by the Web api Get method parameter.
From Postman Get Method() ->
http://localhost:60670/api/home?query=#
"query" is the parameter for search, in that i have given "+" or "#" keyword.
public IActionResult Get(string query)
But from the code it is not recognized by the Get method and "query" parameter is showing "null".
Help on this please!

few ways to do it:
1- encode your parameters : + --> %2B and # --> %23 (and any other special character) SEE : http://www.degraeve.com/reference/specialcharacters.php
2- send via POST instead of GET (I prefer this)

Encode your parameters:
original path = \Documents\FDS_D7U_C180175P+001005.pdf
encode path = %5C%20Documents%5CFDS_D7U_C180175P%2B001005.pdf
Enter the encoded path on the postman.
click on send.

Related

Web service Automation through Karate Framework using Cucumber

I am facing the following issue:
I am writing web service automation testing using Intuit Karate framework through BDD Cucumber in Eclipse.
We are using "Scenario Outline" and passing value by "Examples" like this:
#parallel=false
#sanity
Feature: Data Integration
Background:
* url baseUrl
* configure ssl = true
Scenario Outline: Generating csrf
Given url securityChkUrl
* print 'securityChkUrl in POST : ' , securityChkUrl
And param type = 'json'
And form field j_username = "<UserID>"
And form field j_password = "<Password>"
And header X-CSRF-TOKEN = csrf
When method POST
Then status 200
And def csrfAfterLogin = responseHeaders['X-CSRF-TOKEN'][0]
* print 'csrf token after successful login is : ' , csrfAfterLogin
Examples:
|UserID|Password|
|Prosenjit123|Prosenjit#123456|
I want to pass a value as a variable instead of passing the value itself.
For example: instead of sending Prosenjit123 and Prosenjit#123456 as above, I would like to send userName and PasswordForUserName which will contain these values.
This doesnt seem to work, How could I do it?
Thanks
Prosenjit
You can store the post response and CSRF token in the class/global variables(decide based on the language variable scope), then update your step to use the variable in the step def.

Azure proxies don't accept query string parameters as request overrides

I'm trying to call my azure proxy function with query string parameters.
I don't want to pass my params as route parameters, I want to do it with query string params as to not break my current contract.
My url is as follows https:/<mrUrl>.net/api/address-suggestions
I then have some static request overrides parameters that work fine.
Lastly I call the api as https:/<mrUrl>.net/api/address-suggestions?limit=10&query=main
In my proxies.json I have
"requestOverrides": {
"backend.request.method": "get",
"backend.request.querystring.api-version": "1.0",
"backend.request.querystring.countrySet": "US",
"backend.request.querystring.typeahead": "true",
"backend.request.querystring.query": "{query}",
"backend.request.querystring.limit": "{limit}"
}
That seems to be the only way to do what I want, but my response is always "query parameter is missing or empty" (note if I hard code the query in the JSON it works). Am I to assume there is no support for send query string params and only support for route params?
I found it for anyone looking. Use request.querystring.<yourQuerystringName>

How to display actual value of a property which is using property expansion

I require some help on being able to get around displaying an endpoint from a SOAP Request.
Below I have a piece of code which retrieves an endpoint from a SOAP Request named 'TestAvailability' and outputs it to a file (the code is within a groovy script step).
def endpoint = testRunner.testCase.getTestStepByName('TestStep').get
Now here is the catch, in the file it outputs the endpoint as so:
ENDPOINT: ${#Project#BASE_URL}this_is_the_endpoint
The reason it displays ${#Project#BASE_URL} is because this is a variable set at project level so that the user can select their relevant environment from a drop down menu and that value will be displayed for the variable: ${#Project#BASE_URL}
But I don't want the project variable to be displayed but instead its value like so if ${#Project#BASE_URL} is set to 'testenv'
ENDPOINT: testenv_this_is_the_endpoint
My question is how do I change the code in order to display the endpoint correctly when outputted to a file?
You have a trivial issue. Since it is using property expansion in the endpoint, it request to expand it.
All you need is to change below statement
From:
testResult.append "\n\nENDPOINT: " +endpoint
To:
testResult.append "\n\nENDPOINT: ${context.expand(endpoint)}"

Swagger API "required" - how much is this required?

I've created a Swagger (on nodejs/express) test API with this specification (only relevant part):
...
parameters:
- name: name
in: query
required: true
type: string
...
But I can call the url with empty paramter, for example
http://localhost/test?name=
And it works without any problem, throws no exception or any other sign. Why?
If I make a similar call from the terminal via curl or via postman, it works as well. I parsed the query from the request object and found that in this case, the query parameter is interpreted as an empty string.
Making the call via SwaggerUI is different though, as the UI will actually not make the call UNLESS the query field has a value.
Try doing console.log(req.query); in your handler. You will probably see {name: ''}. Which is legitimate, just that the value of name is an empty string.
Look at JSON4 here: Representing null in JSON. So name IS defined, but it's empty.
You will probably need to do a check for empty string values.
I hope this helps!

Using 'querystring.parse' built-in module's method in Node.JS to read/parse parameters

Scenario:
Consider the following code:
var querystring = require('querystring');
var ParamsWithValue = querystring.parse(req._url.query);
Then I am able to read any query string's value.
E.g: If requested string is http://www.website.com/Service.aspx?UID=Trans001&FacebookID=ae67ea324
I can get the values of query string with codes ParamsWithValue.UID & ParamsWithValue.FacebookID respectively.
Issue: I am able to get the values of any number of parameters passed in the same way described above. But for second time onwards I am getting the following error in response on browser.
Error:
{"code":"InternalError","message":"Cannot read property 'query' of undefined"}
Question: What is wrong in the approach to read the query string from the URL.
Note: I don't want to use any frameworks to parse it. I am trying to depend on built-in modules only.
Update: It responds correctly when the value of any of the parameter is changed. But if the same values requested again from even different browser it throws same error.
I think you need req.url rather than req._url.
req.url is a string, if you want a URI instance use require('url').parse(req.url)
So, you should finally have:
var ParamsWithValue = querystring.parse(require('url').parse(req.url).query);
Edit: I corrected a typo in point 1, the last req.url -> req._url

Resources