【问题标题】:Postman giving different response邮递员给出不同的回应
【发布时间】:2018-07-04 13:40:09
【问题描述】:

我是 swift iOS 的初学者,我正在 iOS 中做一个应用程序的登录模块,但我被困在一件事上,我有登录 api,但是当我在邮递员中检查响应时,我将参数发送为“原始”而不是它显示用户已登录,但是当我发送与“表单数据”相同的参数时,它显示错误的 ID 和密码......谁能告诉我如何将参数作为“原始”发送,以便我可以正确回复??谢谢你的帮助!!

【问题讨论】:

  • 请提供您的邮递员请求的屏幕截图。

标签: ios swift post postman


【解决方案1】:

如果您使用 Alamofire 库进行 API 调用,请尝试此方法。

func request(_ method: HTTPMethod
    , _ URLString: String
    , parameters: [String : AnyObject]? = [:]
    , headers: [String : String]? = [:]
    , onView: UIView?, vc: UIViewController, completion:@escaping (Any?) -> Void
    , failure: @escaping (Error?) -> Void) {

    Alamofire.request(URLString, method: method, parameters: parameters, encoding: JSONEncoding.default, headers: headers)
        .responseJSON { response in


            switch response.result {
            case .success:                 
                completion(response.result.value!)
            case .failure(let error):

                failure(error)
            }
    }
}

另外请记住,在调用此方法时您需要传递 Application/JSON 标头。

["Content-Type": "application/json"]

【讨论】:

    【解决方案2】:

    发件人:http://toolsqa.com/postman/post-request-in-postman/

    检查您的 raw 是否使用下面指定的正确格式类型。

    【讨论】:

      猜你喜欢
      • 2017-09-11
      • 1970-01-01
      • 1970-01-01
      • 2023-03-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2016-11-22
      • 2021-10-05
      相关资源
      最近更新 更多