I am trying to use google geocoding. If i just type
https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=true
it gives me right output. I am trying to use this with a amazon proxy server and it gives
{ "error_message" : "The 'sensor' parameter specified in the request must be set to either 'true' or 'false'.", "results" : [], "status" : "REQUEST_DENIED" }
This the code
http://ec2-00-000-000-000.compute-1.amazonaws.com/OsProxy/getpage.aspx?p=https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=true
Can someone help me?
Thanks
Rashmi
You need to URL-encode your parameters. Consider the URL you're using:
http://ec2-00-000-000-000.compute-1.amazonaws.com/OsProxy/getpage.aspx?p=https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&sensor=true
This is parsed as:
http://ec2-00-000-000-000.compute-1.amazonaws.com/OsProxy/getpage.aspx?
p=https://maps.googleapis.com/maps/api/geocode/json?address=1600+Amphitheatre+Parkway,+Mountain+View,+CA&
sensor=true
That is, you're passing the sensor parameter to amazonws.com, not to googleapis.com.
Since the only parameter to amazonws.com should be the full URL, encode that URL so it reaches amazonws.com as a single parameter to be passed through to googleapis.com:
http://ec2-00-000-000-000.compute-1.amazonaws.com/OsProxy/getpage.aspx?p=https%3A%2F%2Fmaps.googleapis.com%2Fmaps%2Fapi%2Fgeocode%2Fjson%3Faddress%3D1600%2BAmphitheatre%2BParkway%2C%2BMountain%2BView%2C%2BCA%26sensor%3Dtrue
Related
I'm having trouble with passing in parameters to a get request. This request is intended to return a list of warehouses after the user entered some search parameters such as Date, State, ZIP and/or warehouse number, which is the only mandatory field. So when the search button is pressed the query is executed, but im getting this error:
2021-04-19 15:49:00 +0000
2021-11-02 13:06:44.670511-0600 WAREHOUSE_IOS-Master[3142:186324] GET method must not have a body
2021-11-02 13:06:44.670799-0600 WAREHOUSE_iOS-Master[3142:186324] Task <C7839029-C527-490E-8747-137012285F14>.<3> finished with error [-1103] Error Domain=NSURLErrorDomain Code=-1103 "resource exceeds maximum size" UserInfo={NSLocalizedDescription=resource exceeds maximum size,
error: invalidResponse
Okay so what im doing is passing a body to the get request that includes the search parameters as such:
struct WarehouseBody : Codable {
let dateRegistration : String?
let state : String?
let zip : String?
let warehouseNumber : String
}
and I'm expecting a response of this type:
struct WareHouseResponse: Codable {
let status: String?
let code: Int?
let responseCode, message: String?
let error: Bool?
let errorMessage: String?
let result: Result?
enum CodingKeys: String, CodingKey {
case status = "Status"
case code = "Code"
case responseCode = "ResponseCode"
case message = "Message"
case error = "Error"
case errorMessage = "ErrorMessage"
case result = "Result"
}
}
but according to what I've reading on other posts this is not the correct way of using a get request, but I really really need to do some testing. Is there a way that I can achieve this without needing to alter the backend? Just to mention that I ´m also the developer of the backend (c# using .net framework and dapper)so if the easiest way is to achieve this is by altering it I can also do that. Any ideas are very much appreciated.
On the backend I was thinking of implementing a post Request that sends the search parameters to the server and then a get request that pulls out the requested information, but I don't know if that's the correct approach. But this not feasible at the moment because the Web API are already publish and I cannot re publish with the changes at the moment, and is really urgent to test the response so that's why I would like to know if all this can be done from the front end first. Thank you very much for all the help!
Thank you very much for your help!
EDIT: Also I forgot to mention that the api has been previously tested on POSTMAN and is working perfectly.
Since iOS 13. you cannot pass in parameters to a GET request. There’s no easy way around this. You need to change your request from a GET to a POST on the backend. In my case, this was an easy task because I had access to the API source— but, if you don’t, just ask the backend team to change it, and pass in the parameters as in any other POST request. That should work.
I have an issue with this get request of bugzilla to get the page of bug_list of two bugs "http://10.0.6.199:8080/bugzilla/rest.cgi/bug?id=2313,3478?api_key=my_api_key"
The issue appeared when I write more than one bug id to get the page of bug_list, I get this response
{
"code" : 410,
"documentation" : "http://www.bugzilla.org/docs/tip/en/html/api/",
"error" : true,
"message" : "You must log in before using this part of Bugzilla."
}
but I have no issus when I write one id by this get request
http://10.0.6.199:8080/bugzilla/rest.cgi/bug/2313?api_key=my_api_key
Can any one tell me the problem with this get request link?
I got the problem, I should write '&' before api_key instead of '?'
http://10.0.6.199:8080/bugzilla/rest.cgi/bug?id=2313,3478&api_key=my_api_key
instead of
http://10.0.6.199:8080/bugzilla/rest.cgi/bug?id=2313,3478?api_key=my_api_key"
I'm currently trying to send a post request with a user agent however I get errors every time I try to use a user agent. Please may someone help?
I've already tried:
request.Headers.Add("User-Agent", "{My user agent}");
I get this error when I try to use the code above:
System.ArgumentException: 'The 'User-Agent' header must be modified using the appropriate property or method.
Parameter name: name'
Thanks in advance
Use the HttpRequestHeader.UserAgent instead of a string "User-Agent". That'll fix it.
I'm constructing a gather in C# from Twilio and for the URL attribute of gather constructor I need to pass a query parameter. For example "somepath?name=someName". However, i'm getting an exception saying that my urlString parameter is null. I tried to encode the "somepath?name=someName", but didn't work.
How can I pass query parameters for Twilio gather's URI?
I just urlencoded context data and added it to the path such as "somepath/somedata". The only time I really need to do that was a new call where I didn't already have a CallSid to reference in the backend.
I figured out how to do it. The following solution works:
var gather = new Gather(
new[] { Gather.InputEnum.Speech }.ToList(), new Uri($"{Url.ActionUri(nameof(MethodName), MyControllerName)}?name=some_name", UriKind.Relative), speechTimeout: "auto");
I am working on a requirement where I need to create an 'Epic' issue type first and then I need to create a 'Bug' issue type mentioning the Epic name in it.
I am parsing the following data for adding an Epic in JIRA but its giving me an error:
string json = #"{""fields"":{""project"":{""key"":""SITBIT""},""summary"": ""Test Epic"",""description"": ""Test Epic Description"",""issuetype"": {""name"":""Epic""}}}";
The above code is giving me the below error:
The remote server returned an error: (400) Bad Request.
The above JSON code is working fine for normal issue type however its throwing an error if I changed the Issue type to 'EPIC'.
What could be the issue? How can I parse the JSON so that the epic can be added.
Secondly, When I am parsing the already added Epic name in the normal issue type then also it gave me (400) bad request error.
Different issue types can have different required fields. To create an epic you also need to specify the 'Epic Name', but this field is missing in your request.
You can use the JIRA REST API to verify which fields are required using the /rest/api/2/issue/createmeta resource:
The fields that can be set on create, in either the fields parameter or the update parameter can be determined using the /rest/api/2/issue/createmeta resource. If a field is not configured to appear on the create screen, then it will not be in the createmeta, and a field validation error will occur if it is submitted.
The JIRA REST API documentation also contains more info about how errors are handled. You only mention the message that corresponds to the status code of the response, but the response body will contain more info, for example:
{
"errorMessages": [
"Field 'priority' is required"
],
"errors": {}
}