How i can send a json http request to server?

I have an api url.

The server guy give me the request:

[
    'action' => 'login',
    'parameters' => [
  "email" => '******',
  "password" => '*****'
  ]


How to send that parameters on the server?

The POST name should be: request
Server not recognize array in array?

In android i made it!

To form an HTTP[S] request you need to know:

  • URL — This is passed in when you construct the

    URLRequest
    value.
  • HTTP method — This is set via the

    httpMethod
    property.
  • Any special headers, like

    Content-Type
    — These are set via the
    setValue(_:forHTTPHeaderField:)
    method.
  • The body data — You can set this via the

    httpBody
    property, but it’s more normal to pass it in when you create the
    URLSessionUploadTask
    .

For a JSON request you generally form the body data by construction the relevant native values and then serialising it to data using

JSONSerialization
.

Which of these things do you need help with?

Share and Enjoy

Quinn “The Eskimo!”
Apple Developer Relations, Developer Technical Support, Core OS/Hardware

let myEmail = "eskimo" + "1" + "@apple.com"
How i can send a json http request to server?
 
 
Q