2016-11-22 61 views
0

我试图使用我的登录用户的返回apikey向我的头添加授权,但是它似乎无法工作,因为出现apikey丢失的错误(是来自网络服务的返回错误)如何使用Swift 3.0 + Alamofire 4.0在头上添加授权

func getFavourites() 
{ 

    let headers = ["Content-Type": "application/x-www-form-urlencoded", "authorization" : user.apiKey ] 

    Alamofire.request("http://localhost:8888/food_pin/v1/restaurantToFavourites", method: HTTPMethod.get, encoding: URLEncoding.default, headers: headers).responseJSON { (response:DataResponse<Any>) in 


     if response.result.value != nil 
     { 
      print(response.result.value!) 
      print(response.response!) 
      self.returnAllFavourites(data: response.data!) 
     } 

     else 
     { 
      print(response.result.error!) 
     } 
    } 

} 
+1

你确定它不是'Authorization'吗? – fpg1503

+1

这就是它是如何写在我的web服务我把它改为资本只是为了看到你是对的谢谢你 – giorgos7

+0

我已经添加它作为答案 – fpg1503

回答

0

使用Authorization作为标题密钥。

相关问题