MultipartForm icon indicating copy to clipboard operation
MultipartForm copied to clipboard

Getting unauthorised error from server

Open AnilkumarRabhasa opened this issue 3 years ago • 0 comments

Thanks for the great library, But, I am getting Unauthorised error though I am sending Bearer token to server.

    let form = MultipartForm(parts: [
        MultipartForm.Part(name: "Type", value: "\(categoryType)"),
        MultipartForm.Part(name: "file", data: imageData, filename: "\(imageeData.name)", contentType: "\(mimeType)"),
    ])

    var reequest = URLRequest(url: URL(string: url)!)
    reequest.httpMethod = "POST"
    reequest.setValue(form.contentType, forHTTPHeaderField: "Content-Type")
    reequest.addValue("Bearer \(SessionManager.accessToken ?? "")", forHTTPHeaderField: "Authorization")

The error from sever is below

{ "status" : 401, "message" : "Unauthorized", "timestamp" : "2022-08-12T10:10:26.204+0000", "path" : "/uploadDocument", "error" : "Unauthorized" } Can anyone help/suggest me where I am doing wrong here?

AnilkumarRabhasa avatar Aug 12 '22 10:08 AnilkumarRabhasa