This is my URL http://192.168.173.211:138/googleMaps.asmx/CustomerLocationgAddress_Add?. I am sending parameters like this, but in response I am getting error. The problem is "/" after CustomerLocationgAddress_Add?. How to remove "/"?
http://192.168.173.211:138/googleMaps.asmx/CustomerLocationgAddress_Add?/Zip=2717&First_Name=Sri&Last_Name=Vas&Address1=&Address2=&City=&State=&Zip=&Phone=8125137015&CustomerID=187181&Phone_Type1=&Company_Name=&IsDefault=True
Related
So I am trying to pass a filerepo path as a url parameter in Postman, but it keeps saying its a bad request.
Example:
http://url/api/C:\File
I have also tried the url encoded version, but postman still says bad request:
http://url/api/C%3A%5CFile
I am sending out a GET request like so.
let parameters: Parameters = [
"filter": ["fruit": "apple"]
]
Alamofire.request(urlStr, method: .get, parameters: parameters, encoding:URLEncoding.default).responseJSON { response in
print(response.request!)
}
However, the GET request doesn't work correctly. I believe the parameters are not correct at all. This is the URL request that is printed out using the following code print(response.request!)
https://api.example.com/fruits?apiKey=1&filter%5Bfruit%5D=apple
However, using postman I can send the correct request and get the correct response using the following URL request.
https://api.example.com/fruits?apiKey=1&filter={"fruit":"apple"}
I don't know how to fix this. I tried many encoding types, but none of it worked. Any tips or suggestions are appreciated
Edit: I do get a response from the server using alamofire, but it isn't correct data because the paramters are ignored. However, the response I get from postman is correct.
Morning Curt,
Since there is no published specification for how to encode collection types, the convention of appending [] to the key for array values (foo[]=1&foo[]=2), and appending the key surrounded by square brackets for nested dictionary values (foo[bar]=baz) [is used].
In my opinion you should really avoid passing array objects in query strings. You could change your request to something like:
apiKey=1&fruit=apple
Where does presence of field fruit itself indicates response should be filtered.
Moreover:
Instead of using GET, you should consider using POST or PUT and passing values via JSON, XML, or another well-defined format. This could require server side changes obviously.
If server side is out of your control, you should consider manually encoding these parameters instead.
Source
You can find here an example of manually encoding.
Happy coding!
I am working on a restful service in asp.net MVC 4 Web API. I have a get method that getting a url encoded data as a parameter from URI. But, the thing is when I try this method from RESTClient (firefox tool), I am getting 404. And when i check the stack trace my url seems with non encoded parameter. You can see the example below:
Url format: /api/Applications/key
I am sending this:
/api/Applications/3baxYhYzpVGTrIIzs4CvGv4KIcIRHn5yqx%2F9a5PzTJxK4SWVcwi9GI6bib9pe1psk%2FdYeD0EaOdMHZpzWl%2Fbwg%3D%3D
In the response body, request url seems like this;
/api/Applications/3baxYhYzpVGTrIIzs4CvGv4KIcIRHn5yqx/9a5PzTJxK4SWVcwi9GI6bib9pe1psk/dYeD0EaOdMHZpzWl/bwg==
I am getting an error because of escape characters. I can use post but I want to go on with restful architecture.
Any advice will be appreciated.
I have been using curl & Postman on Chrome to send http POST requests with one variable to an simple HTTP server I have running and I have noticed that they construct the requests slightly differently. Apologies if I might have used any incorrect terminology in constructing the question - I'm still learning this stuff.
Using Postman, the request is constructed by putting a '?' between the resource name and the variable. E.g.
http://192.168.0.2:9999/1/command?a=b
However, the following curl command:
curl -X POST http://192.168.0.2:9999/1/command --data a=b
does not put a '?' between the resource name and the variable.
The result is that the HTTP server interprets the requests differently.
In the first case, the body of the request is empty and in the second case the body contains a=b.
Which version is correct?
Constructing curl , python request , using HTTP POST
Open postman client and click on code [Below save button ] refer snapshot .
when click on code another window appears . refer snapshot .
similarly you can generate various other request [curl , python ,java , php ] refer snapshot
You can refer below link
http://jmeterblogb.blogspot.in/2016/11/constructing-curl-from-python-http-php.html
POST requests post data as part of the request body and GET requests via URL parameters. If you choose the form data option in postman you can pass it the same way (request body) in postman as well. How are parameters sent in an HTTP POST request? may be worth reading.
I want to make an HTTP GET request from my iOS client and place in the request params. I have written code that performs a POST request, where it was very easy to use setHTTPBody to place a NSData* object in the request. How is this done for a GET request?
Thanks
In a GET method the parameters are passed in the query string - so you suffix your URL with something like ?param1=value1¶m2=value2¶m3=value3. You may need to percent-encode your query string if it contains characters like space, & or =