Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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!

like image 451
Gopinath D Avatar asked Oct 21 '25 15:10

Gopinath D


2 Answers

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)

like image 176
nafas Avatar answered Oct 24 '25 21:10

nafas


Encode your parameters:

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

https://i.sstatic.net/xWvRE.png https://i.sstatic.net/ad0XB.png https://i.sstatic.net/ahnxs.png

like image 41
shubham kadam Avatar answered Oct 24 '25 22:10

shubham kadam