NTLM 与 Postman 显示“JSONError |意外的标记 '<'在 1:1 " [英] NTLM with Postman shows "JSONError | Unexpected token '<' at 1:1 "

查看:162
本文介绍了NTLM 与 Postman 显示“JSONError |意外的标记 '<'在 1:1 "的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有脚本来执行 API 自动化,方法是从 CSV 文件中获取数据并将 JSON 响应与 POSTMAN 中的 CSV 文件中的数据进行比较.我有 12 个场景/迭代需要验证,每个场景发送 20 多个从 CSV 文件和 JSON 响应中挑选的数据,比较了 10 多个数据.一切正常.

现在在代码中实现了安全功能,所以我必须发送请求并使用 ID/PWD 自动化脚本.所以我使用了带有 ID 和 PWD 的 NTML 身份验证.

当我使用 runner 运行脚本时,最初的两次迭代给出了完美的响应并且脚本通过了,然后从第三次迭代开始,所有脚本都失败了并且没有得到响应.作为回应,当我在邮递员控制台中检查时,它显示数据不可用,它显示以下详细信息.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><头><meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/><title>401 - 未经授权:由于凭据无效,访问被拒绝.</title><style type="text/css"><!--body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}字段集{padding:0 15px 10px 15px;}h1{font-size:2.4em;margin:0;color:#FFF;}h2{font-size:1.7em;margin:0;color:#CC0000;}h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;背景色:#555555;}#content{margin:0 0 0 2%;position:relative;}.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}--></风格><身体><div id="header"><h1>服务器错误</h1></div><div id="内容"><div class="content-container"><fieldset><h2>401 - 未经授权:由于凭据无效,访问被拒绝.</h2><h3>您无权使用您提供的凭据查看此目录或页面.</h3></fieldset></div>

</html>

可能是什么原因以及解决此问题的任何解决方案.

屏幕短片

使用带有 ID/PWD 的 NTLM 身份验证 [BETA] 授权选项

这里是通过场景的详细信息

请求头:内容类型:应用程序/json"缓存控制:无缓存"用户代理:PostmanRuntime/7.1.5"接受:"*/*"主持人:xxxxxx"接受编码:gzip,放气"内容长度:599授权:NTLM TlRMTVNTUAADAAAAGAAYAFIAAAAYABgAagAAAAAAABIAAAACgAKAEgAAAAAAAAAUgAAAAAAAACCAAAABYKIogUBKAoAAAAPUAAzAFcATABJAPxv7ESeMEwAAAAAAAAAAAAAAAAAAAAAAHZECYztsK+qnjG5K0DvDvDIPz0"请求正文:响应头:传输编码:分块"内容类型:应用程序/json;字符集=utf-8"位置:xxxxxx/api/rate/zzz"服务器:红隼"持久身份验证:真"日期:格林威治标准时间 2018 年 6 月 6 日星期三 13:40:05"响应机构:率:5零售率属性:错误:空

这里是失败场景的详细信息

 请求头:内容类型:应用程序/json"缓存控制:无缓存"授权:NTLM TlRMTVNTUAADAAAAGAAYAFIAAAAYABgAagAAAAAAABIAAAACgAKAEgAAAAAAAAAUgAAAAAAAACCAAAABYKIogUBKAoAAAAPUAAzAFcATABJAPxv7ESeMEwAAAAAAAAAAAAAAAAAAAAAAHZECYztsK+qnjG5Q0DvDvDIPoz0"用户代理:PostmanRuntime/7.1.5"接受:"*/*"主持人:""xxxxxx""接受编码:gzip,放气"内容长度:599请求正文:响应头:内容类型:文本/html"服务器:Microsoft-IIS/10.0"www-认证:0:协商"1:NTLM"日期:格林威治标准时间 2018 年 6 月 6 日星期三 13:40:05"内容长度:1293"响应机构:

解决方案

我收到了 Postman 错误消息JSONError: 意外标记 '<'在 1:1^ 今天.
我意识到问题(就我而言)是我试图访问一个 API自己写的,忘记上传了.- 因此,我尝试调用 API那并不存在.(!)

我一上传 API,错误就消失了.

I have script to do API automation by fetching data from CSV file and comparing JSON response with the data in CSV file in POSTMAN. I have 12 scenarios/ iterations to verify and each scenario sends more than 20 data picking from CSV file and from JSON response compared more than 10 data. Everything is working fine.

Now Security feature implemented in code, so I have to send the request and Automate the script with ID/PWD. So I used NTML authentication with ID and PWD.

When I run the script with runner, initial two iteration gives perfect response and script passed, then from 3rd iteration all script failed and not getting response. In response it says Data unavailable when I checked in postman console it shows below details.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
<title>401 - Unauthorized: Access is denied due to invalid credentials.</title>
<style type="text/css">
<!--
body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
fieldset{padding:0 15px 10px 15px;} 
h1{font-size:2.4em;margin:0;color:#FFF;}
h2{font-size:1.7em;margin:0;color:#CC0000;} 
h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;} 
#header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
background-color:#555555;}
#content{margin:0 0 0 2%;position:relative;}
.content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
-->
</style>
</head>
<body>
<div id="header"><h1>Server Error</h1></div>
<div id="content">
 <div class="content-container"><fieldset>
  <h2>401 - Unauthorized: Access is denied due to invalid credentials.</h2>
  <h3>You do not have permission to view this directory or page using the credentials that you supplied.</h3>
 </fieldset></div>
</div>
</body>
</html>

What could be the reason and any solution to solve this.

Screen short

Used NTLM Authentication [BETA] authorization option with ID/PWD

Here are the details for pass scenario

Request Headers:
content-type:"application/json"
cache-control:"no-cache"
user-agent:"PostmanRuntime/7.1.5"
accept:"*/*"
host:"xxxxxx"
accept-encoding:"gzip, deflate"
content-length:599
authorization:"NTLM TlRMTVNTUAADAAAAGAAYAFIAAAAYABgAagAAAAAAAABIAAAACgAKAEgAAAAAAAAAUgAAAAAAAACCAAAABYKIogUBKAoAAAAPUAAzAFcATABJAPxv7ESeMEwAAAAAAAAAAAAAAAAAAAAAAHZECYztsK+qnjG5K0DvDIPzQ09CFXWo0Q=="

Request Body:

Response Headers:
transfer-encoding:"chunked"
content-type:"application/json; charset=utf-8"
location:"xxxxxx/api/rate/zzz"
server:"Kestrel"
persistent-auth:"true"
date:"Wed, 06 Jun 2018 13:40:05 GMT"

Response Body:
rate:5
retailRateAttributes:
error:null

Here are the details of Failed scenario

   Request Headers:
content-type:"application/json"
cache-control:"no-cache"
authorization:"NTLM TlRMTVNTUAADAAAAGAAYAFIAAAAYABgAagAAAAAAAABIAAAACgAKAEgAAAAAAAAAUgAAAAAAAACCAAAABYKIogUBKAoAAAAPUAAzAFcATABJAPxv7ESeMEwAAAAAAAAAAAAAAAAAAAAAAHZECYztsK+qnjG5K0DvDIPzQ09CFXWo0Q=="
user-agent:"PostmanRuntime/7.1.5"
accept:"*/*"
host:""xxxxxx""
accept-encoding:"gzip, deflate"
content-length:599

Request Body:

Response Headers:
content-type:"text/html"
server:"Microsoft-IIS/10.0"
www-authenticate:
0:"Negotiate"
1:"NTLM"
date:"Wed, 06 Jun 2018 13:40:05 GMT"
content-length:"1293"

Response Body:

解决方案

I got the Postman error message JSONError: Unexpected token '<' at 1:1<!doctype html>^ today.
I realized that the problem (in my case) was that I tried to access an API that I had written myself, but forgotten to upload. - Thus, I tried to call an API that did not exist. (!)

As soon as I uploaded the API, the error went away.

这篇关于NTLM 与 Postman 显示“JSONError |意外的标记 '&lt;'在 1:1 &quot;的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆