X-RequestDigest:运行共享点页面的录制的Web测试时出错 [英] X-RequestDigest: Getting error while running recorded web test of sharepoint page

查看:177
本文介绍了X-RequestDigest:运行共享点页面的录制的Web测试时出错的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经成功录制并重播了共享点Web测试,但是在一两周后,在Visual Studio中重播它时,出现"403 FORBIDDEN"错误.

I have recorded and replayed my sharepoint webtest successfully but after a week or two, I get '403 FORBIDDEN' error when I replay it in Visual Studio.

我了解X-RequestDigest已过期的证书/令牌详细信息,需要针对我的请求中的每次运行进行更新. 但是,我在录制的Web测试中找不到先前的X-RequestDigest标头值.

I understand that X-RequestDigest has expired certificate/token details and needs to be updated for every run in my request. However, I'm unable to find preceding X-RequestDigest header value in my recorded web test.

我能够从响应标头中提取,但是我需要在响应之前将值绑定到请求吗? 有人可以给我代码/方法从Sharepoint页面提取X-RequestDigest标头值并在我的Visual Studio Webtest中使用它吗?

I'm able to extract from response header but I need to bind the value to request prior to response? Can someone give me a code/method to extract X-RequestDigest header value from Sharepoint page and use it in my Visual Studio Webtest?

推荐答案

问题的答案可能会有所不同,具体取决于您使用的SharePoint版本.通常,可以从_api/contextinfo中提取x-requestdigest值,该值出现在您需要参数化的请求之前.这是一个JSON响应正文,如下所示:

Answer to your question may vary depends on the version of SharePoint you use. Typically the x-requestdigest value can be extracted from _api/contextinfo that appears just before the request that you need to parameterize. This is a json response body that looks as follows:

{"d":{"GetContextWebInformation":{"__ metadata":{"type":"SP.ContextWebInformation"},"FormDigestTimeoutSeconds":1800,"FormDigestValue":"0x258D3700E8E516F8E320BAF6FEFDDC271C54C8C44A1E5DBE9B9E9E4DB9E9B2E9B2E9B1E1E9DBE9E79B1E1E1E1E1E1E0E1E1E0E1E1E0E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E1E4D1E4E1E4E1E1E4D1E4E1E4E1E4D0760E1E1760E 2017年6月10:26:21 -0000," LibraryVersion:" 16.0.5521.1202," SiteFullUrl:" https://xxx.sharepoint.com ," SupportedSchemaVersions:{" __ metadata:{" type:" Collection(Edm.String)},"结果:[" 14.0.0.0," 15.0.0.0]}," WebFullUrl:" https://xxx.sharepoint.com/Sample_Site }}}

{"d":{"GetContextWebInformation":{"__metadata":{"type":"SP.ContextWebInformation"},"FormDigestTimeoutSeconds":1800,"FormDigestValue":"0x258D3700E8E516F8E320BAF6FEFDDC271C54C8C44A1E5DBE8B9CBE6ED2A77EDCCF88CAA901790245D3E9B518FB31AA9B345B0E232C93CD39D4E12999499B7414,6 Jun 2017 10:26:21 -0000","LibraryVersion":"16.0.5521.1202","SiteFullUrl":"https://xxx.sharepoint.com","SupportedSchemaVersions":{"__metadata":{"type":"Collection(Edm.String)"},"results":["14.0.0.0","15.0.0.0"]},"WebFullUrl":"https://xxx.sharepoint.com/Sample_Site"}}}

您需要从此处使用提取文本"提取器提取"FormDigestValue"值.设置开头为:"FormDigestValue":结尾为:"

From here you need to extract the "FormDigestValue" value with an Extract Text extractor. Set the Starts With: "FormDigestValue":" Ends With: "

如果您希望按照AdrianHHH的建议使用Fiddler,则可能还需要使用我们的免费StresStimulus加载项,该加载项将自动创建所有提取器和参数,如此处所述

If you wish to use Fiddler as AdrianHHH suggested, you may also want to use our free StresStimulus add-on that will create all extractors and parameter automatically as described here http://www.stresstimulus.com/blog/post/visual-studio-load-testing-fixing-playback-errors-in-web-tests. You just need to record the test scenario, save it as a webtest and open in Visual Studio. That way, you don’t have to create any extractors and parameters manually.

这篇关于X-RequestDigest:运行共享点页面的录制的Web测试时出错的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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