0
私はこのエラーに直面しています。私の古いプロジェクトでは表示されませんでした。 I API POSTリクエストAlamofireリクエスト "status_code" = Xcodeの401 =
let urlstr = "http://localhost:8000/api/auth/login/"
let url = URL(string: urlstr)
var param = ["email": "[email protected]", "password":"111111"]
request(url!, method: .post, parameters: param)
.responseJSON { response in
print(response.request) // original URL request
print(response.response) // HTTP URL response
print(response.data) // server data
print(response.result) // result of response serialization
if let json = response.result.value {
print("JSON: \(json)")
//Now you got your value
print("username\(json)")
}
}
は私のInfo.plistは
<key>NSAppTransportSecurity</key>
<dict>
<key>NSAllowsArbitraryLoads</key>
<true/>
</dict>
を持っていないが、最近、私はこのエラーに
SUCCESS
JSON: {
message = Unauthorized;
"status_code" = 401;
}
username{
message = Unauthorized;
"status_code" = 401;
}
電話をかける権限があることを確認しましたか?それはAlamofireのエラーではないようです。 –
@RashwanL別のプロジェクトから同じ呼び出しを行ったときに** apicallsを取得するため、私はそうは思わないと思います[16090:8712574] App Transport Securityは平文HTTP(http://)リソースの読み込みをブロックしていますそれは安全ではない。一時的な例外は、アプリのInfo.plistファイルで設定できます。 オプション(http:// localhost:8000/api/auth/signup /) nil オプション(0バイト) FAILURE **ただし、postmanはログイントークンをエラーなしで返します。 – leo0019
あなたはサーバー側からどのようなサービスを呼び出す必要があるかを確認する必要があります。おそらく、この問題はサーバー側からのものになるでしょう。 @ leo0019 –