Swift Post request ,Django backend

After posting encoded data ,I got this resut

<QueryDict: {'{"username":"test","password":"test","error_msg":""}': ['']}>

This is my code

let loginData = LoginModel(username:email, password: password,error_msg: "")
    let encoder = JSONEncoder()

    guard let encoded = try?encoder.encode(loginData)else{
      print("fail to encode")
      return
    }
     
    print(String(data: encoded, encoding: .utf8))
    print("ok")
    var request = URLRequest(url: url)
    request.httpMethod="POST"
    request.addValue("application/json", forHTTPHeaderField: "Accept")
    request.httpBody = encoded

what should I do?

what should I do?

Provide more information about your problem. 😉 What is that “result” string: the body of the server response, something in the server log, something else? Assuming you get a valid HTTP response (though not shown in your code), what is the status code: 200? 4XX? What is the body of the response?

You don’t set a Content-Type: application/json header. Does your server require that header in order to handle the request?

Swift Post request ,Django backend
 
 
Q