Skip to content

Getting unauthorised error from server #4

@AnilkumarRabhasa

Description

@AnilkumarRabhasa

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?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions