Question: I am trying to request an API in order to get response data. I need to add to headers in the request what I have done using request.addValue(""). It works fine when I am using postman. But I don't why I got no data with Xcode. The response is 403 Forbidden

```
class Service {
    private static let sUrl = URL(string: "https://bff-mobile-dev.XXXXX.com/demands/filter")!

static func getData() {
    var request = URLRequest(url: sUrl)

    request.httpMethod = "POST"
    let session = URLSession(configuration: .default)
    request.addValue("Accept-Version", forHTTPHeaderField: "3.0.0")
    request.addValue("X-Request-Id", forHTTPHeaderField: "057BC3BD-46E1-4125-9F3B-23805CA3132F")

    let task = session.dataTask(with: request) { (data, response, error) in
        if let data = data, error == nil {
            if let response = response as? HTTPURLResponse {
                print(response)
            }
        }
    }
    task.resume()

}
} 

```

Answer: 
I believe your key value pair is mixed up when you added the header fields.

```
request.setValue(value,forHTTPHeaderField: "HeaderFieldName")

```

Adding like this works.
Try something like below

```
var headerData:[String:String] = [:]
headerData["Accept-Version"] = "3.0.0"
headerData["X-Request-Id"] = "057BC3BD-46E1-4125-9F3B-23805CA3132F"
request.allHTTPHeaderFields = headerData

```