I'm trying to understand the structure of a URL, and I'm seeing a lot of
%2C. I'm guessing this is a result of some encoding. What does that stand for?
How to sent POST request with content-type = application/x-www-form-urlencoded.Given an access code, I am trying to get the AccessToken using POST request where I have all the information set in POST URL so i don't know what to pass as Http content in the postAysnc method.
According to another post For application/x-www-form-urlencoded, the body of the HTTP message sent to the server is essentially one giant query string -- name/value pairs are separated by the ampersand (&), and names are separated from values by the equals symbol (=). An example of this would be:
So I have similar case where my POST url has all the information as querystring, in that case I don't know what to pass as HttpContent in the postAysnc method since its a mandatory parameter
HttpClient client = new HttpClient();StringContent queryString = new StringContent(data);HttpResponseMessage response = await client.PostAsync(new Uri(url), queryString );
If I encode a string like this:
var escapedString = originalString.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)
it doesn't escape the slashes
I've searched and found this Objective C code:
NSString *encodedString = (NSString *)CFURLCreateStringByAddingPercentEscapes( NULL, (CFStringRef)unencodedString, NULL, (CFStringRef)@"!*'();:@&=+$,/?%#", kCFStringEncodingUTF8 );
Is there an easier way to encode an URL and if not, how do I write this in Swift?
When implementing OAUTH, I have the following problem. When creating the signature base, should encoded parameters be encoded again or should encoded parameters be left out of the encoding when normalizing parameters?
I am trying to urlencode this string before I submit.
queryString = 'eventName=' + evt.fields["eventName"] + '&' + 'eventDescription=' + evt.fields["eventDescription"];