当前位置: 动力学知识库 > 问答 > 编程问答 >

Jmeter 401 failure on POST with json recorded using recording controller

问题描述:

I recorded actions on a web page using the Recording Controller and HTTP Script Recorder in JMeter. For one of the POST commands JMeter recorded, JMeter put json into the field "Send Parameters in the Request" when it recorded my action of pressing the "Send" button on the web page I was on. I then took the web page hits recorded under the Recording Controller and moved them up under my test case in JMeter. Then, I ran the test case, with these new recorded http requests ( including the one with the json filled int under "Send Parameters in the Request" ). Most of the web page hits are simulated correctly in JMeter and do not fail in the Summary Report since they have 0% error in the Summary Report. This includes a "sign in" to the web site. However, after signing in successfully, when the "Send" button is simulated in JMeter, I see 100% Error in my Summary Report, the test case stops running there, and no other http requests after this point are simulated. Basically, JMeter stops right there even though there is more in my test case that JMeter could run.

So, I searched and found that I may need to extract the json. However, it looks like the json was already put there by JMeter in "Send Parameters in the Request" from when JMeter recorded my actions using the Recording Controller earlier.

  1. Is the json that JMeter put there when it recorded my actions incorrect or in an incorrect form?

  2. If it is in an incorrect form, where do I get the json from? I do not see the json in any part of my test case before this failed POST command with the 401 error. Like I said, it appears like JMeter just knows about this json and puts it into that POST command.

  3. When I do find out where the json is coming from, how do I use a json extractor? More specifically, do I need to build the same json string or do I need to feed parts of the json into variables and send variables with the POST command? If this is true, how do I know what variables to send? Is this where I check the View Results Tree? ( Do I look under "Sampler Result", "Request", or "Response Data" ? )

网友答案:

So, I actually focused more on the 401 error which was an authorization error. The user that was hard coded in a previous post was no longer in the database for a different reason now. So, once I changed the user to a user that existed, the 401 error went away.

So, back to the json that this was originally about for future researchers. The Recording Controller, in my case, was recording the json correctly the whole time. I made no changes to any of the json. Once I had a valid user, I was able to see json returned to me under "Response data". Once I saw the json under "Response data" for this POST command while viewing the "View Results Tree", everything made sense to me since I was receiving something back from the server.

分享给朋友:
您可能感兴趣的文章:
随机阅读: