You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
As I understand - POST request only possible with json string -
is it true?
Can you make POST request with any string(example - dataForm)?
Can you give example how to make POST request?
Can you explain this part of swift code -
if (method.rawValue == "POST" || method.rawValue == "PUT"){
request.httpBody = try? JSONSerialization.data(withJSONObject: params, options: [])
The text was updated successfully, but these errors were encountered:
The request object for POST is expecting a Data type (see here). NetworkUtills is a wrapper built around the Foundation URL Loading System to make it easier to pass in data. NetworkUtils is expecting a JSON style object ([String: Any]) to be passed in.
If you take a look at this line you will see the arguments it's expecting.
Here is an example of how to use it:
let jsonDict: [String: Any] = ["key1": "val1", "key2": 2]
networkUtils.post("https://www.myapi.com/endpoint", jsonDict).then { (data) in
// Data response from server
}.catch { (error) in
// Error response
}
As I understand - POST request only possible with json string -
is it true?
Can you make POST request with any string(example - dataForm)?
Can you give example how to make POST request?
Can you explain this part of swift code -
if (method.rawValue == "POST" || method.rawValue == "PUT"){
request.httpBody = try? JSONSerialization.data(withJSONObject: params, options: [])
The text was updated successfully, but these errors were encountered: