nsmutableurlrequest

Error 405: Unable to Upload a Custom Playlist Cover Image

落爺英雄遲暮 提交于 2021-01-29 18:34:38
问题 I want to upload a playlist image from my iOS application to the Spotify Web API. I followed the instructions on the docs page: I requested the ugc-image-upload , playlist-modify-public and playlist-modify-private scopes, added the content type header and made a jpeg Base64 String. But I keep getting back a 405 Method Not Allowed error. I am able to create a image with the same URL and Authorization Token on android. I already tried to add the android generated Base64 String to my swift

NSMutableURLRequest POST method with multiple objects

耗尽温柔 提交于 2020-01-07 09:34:42
问题 Below is my POST request example which saves Employee details. This work fine and I'm sending individual employee details. But what if I have to save more then one Employee details...do I have to call below method those many time's ... How can I send all data in individual object like nsmutablearray of nsmutable dictionary.... -(void)saveEmployDetails { NSString * strBody = @"Employee=1&Class=tes&Comp=test&Type=Fixed"; NSString *strUrl = [[NSString alloc] initWithFormat:@"%@/api/external

NSMutableUrlRequest eats plus signs

浪尽此生 提交于 2020-01-01 11:56:27
问题 I create NSMutableUrlRequest for sending data to server, add all necessary fields to it and then add the string for sending like this: [theRequest setHTTPBody:[postString dataUsingEncoding: NSUTF8StringEncoding]]; postString is a usual NSString. The problem is, when I receive this request at the server, all the plus (+) signs disappear from the http body. So if I had "abcde+fghj" on iPhone, I get "abcde fghj" on the server". Can this be some encoding problem from using dataUsingEncoding:

Print NSMutableURLRequest Contents

。_饼干妹妹 提交于 2020-01-01 04:09:06
问题 I want to ask if anybody has ever tried printing out the values of a NSMutableURLRequest *request; Here's my scenario, I have formed my XML and tried sending it using Firefox Poster plugin, I am successful playing with valid and invalid contents, so its time to move into iOS, unfortunately with iOS it doesn't seem to work correctly tho I always get a response of Bad Request (400) which I suspect is caused by a malformed xml content; So I was thinking before sending the request I want to check

Swift: Unable to add .prettyPrinted format String to forHTTPHeaderField

為{幸葍}努か 提交于 2019-12-24 14:19:00
问题 By continuing from this question , I am trying to convert [String : Any] into String and then passing that String into forHTTPHeaderField Attempt 1: Without Pretty let encoder = JSONEncoder() if let json = try? encoder.encode(jsonDict) { convertedString = String(data: json, encoding: .utf8)! } print("JsonStringFormat ", convertedString ) let url = NSURL(string: getMenuURL) let request = NSMutableURLRequest(url: url! as URL) request.setValue(convertedString, forHTTPHeaderField: "SessionInfo")

How to simply test a local Wifi Connection to an IP, for example 192.168.0.100 with code status?

霸气de小男生 提交于 2019-12-24 09:21:37
问题 Do you know if I can simply test if there is a WIFI local connection ? For example if the url 192.168.0.100 is reachable. I tried with the Reachability without success. It tells me that it is connected, but it is not true. I would like first to test if there is a local WIFI connection, and then when I am sure there is a connection, launch that Web Service : - (void)callWebService:(NSString *)url withBytes:(NSString *) bytes //GET { NSMutableURLRequest* request = [[NSMutableURLRequest alloc]

What request headers to use for uploading an image file from iOS to ASP.NET?

倾然丶 夕夏残阳落幕 提交于 2019-12-24 08:32:03
问题 I am building an iOS app where I want to upload images to an ASP.NET MVC server component like the posting of a file in a web page. I have created the NSMutableURLRequest and NSConnection objects in iOS and have verified the call the the .NET server component is working. NSMutableURLRequest *request=[[NSMutableURLRequest alloc]init]; [request setTimeoutInterval:(interval==0?SERVICE_DEFAULT_TIMEOUT_INTERVAL:interval)]; [request setURL:[NSURL URLWithString:[NSString stringWithFormat:@"%@%@"

send HTTP PATCH request in iOS (Objective-c)

六月ゝ 毕业季﹏ 提交于 2019-12-23 05:19:11
问题 I am consuming REST APIs, one of the api is PATCH , i tried to invoke it using following code but it throws error, while same api works in Postman client. + (NSURLSessionTask *)callPATCHAPIWithAPIName:(NSString *)apiName andCompletionHandler:(void(^)(id result, NSInteger responseCode, NSError *error))completionHandler { NSString *getURL = @"192.168.1.100/UpdateDeviceInfo/iPhone6/OS 9.2"; NSURL *URL = [NSURL URLWithString:getURL]; NSMutableURLRequest *request = [[NSMutableURLRequest alloc]

NSURLRequest setValue: forHTTPHeaderField:@“Authorization” not working

主宰稳场 提交于 2019-12-23 00:25:53
问题 I try to make an authenticate call to the twitter API with the Application only Authentication API NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:20.0]; [request setHTTPMethod:@"POST"]; [request setValue:@"application/x-www-form-urlencoded;charset=UTF-8" forHTTPHeaderField:@"Content-Type"]; [request setValue:@"Some App Name" forHTTPHeaderField:@"User-Agent"]; [request setValue

NSURLRequest setValue: forHTTPHeaderField:@“Authorization” not working

|▌冷眼眸甩不掉的悲伤 提交于 2019-12-23 00:24:10
问题 I try to make an authenticate call to the twitter API with the Application only Authentication API NSMutableURLRequest *request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:url] cachePolicy:NSURLRequestReloadIgnoringLocalCacheData timeoutInterval:20.0]; [request setHTTPMethod:@"POST"]; [request setValue:@"application/x-www-form-urlencoded;charset=UTF-8" forHTTPHeaderField:@"Content-Type"]; [request setValue:@"Some App Name" forHTTPHeaderField:@"User-Agent"]; [request setValue