Closed jrlanders closed 7 years ago
@jrlanders just use the put
method, it works the same as post
I will update the documentation for the next release for Swift 3.
Fairly new at this, so I am about to show my ignorance. I am having difficulties getting all the syntax in the right place. Using your example only changing to a put :
try rest.put(addPath, withJSON: postData) { result, httpResponse in do { let json = try result.value() print(json) print(json["url"]?.stringValue) // "http://httpbin.org/post") print(json["json"]?["key1"]?.stringValue) // "value1") } catch { print("Error performing POST: \(error)") } }
I get an Error: Type of expression is ambiguous without more context
Using the swift syntax suggestion and trying to complete that syntax:
try rest.put(addPath, withJSON: postData, withOptions: <#T##(Result<JSON>) -> ()#>){ result, httpResponse in do { let json = try result.value() print(json) print(json["url"]?.stringValue) // "http://httpbin.org/post") print(json["json"]?["key1"]?.stringValue) // "value1") } catch { print("Error performing POST: \(error)") } }
I am unclear how to code the (Result
Any pointers?
@jrlanders what version of Swift/Xcode are you using? This library only works up to the current released version of Swift (2.2). How are you integrating with the library? The released version (1.0.1 in Cocoapods) won't return the httpResponse.
I am going to release 1.0.2 shortly that will add in the example of a PUT and will return the httpResponse as well, stand by.
@jrlanders 1.0.2 was released to cocoapods along with a PUT example. Closing the issue, please feel free to respond to my questions above if you are still having issues.
Would it be possible to show or provide a PUT example with the appropriate syntax?
Thank you