Alamofire Accept and Content-Type JSON

后端 未结 5 1086
心在旅途
心在旅途 2020-12-29 09:48

I\'m trying to make a GET request with Alamofire in Swift. I need to set the following headers:

Content-Type: application/json
Accept: application/json
         


        
5条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-29 09:56

    Try this:

    URLRequest.setValue("application/json",
                        forHTTPHeaderField: "Content-Type")
    URLRequest.setValue("application/json",
                        forHTTPHeaderField: "Accept")
    

提交回复
热议问题