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

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

问题描述

我已成功录制并重播我的 sharepoint webtest,但一两周后,我在 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":{ __元数据":{ 类型": SP.ContextWebInformation"}, FormDigestTimeoutSeconds":1800, FormDigestValue":0x258D3700E8E516F8E320BAF6FEFDDC271C54C8C44A1E5DBE8B9CBE6ED2A77EDCCF88CAA901790245D3E9B518FB31AA9B345B0E232C93CD39D4E12999499B7414,62017 年 6 月 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"}}}

{"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 附加组件,它将按照此处所述自动创建所有提取器和参数 http://www.stresstimulus.com/blog/post/visual-studio-负载测试修复播放错误在网络测试中.您只需要记录测试场景,将其保存为 webtest 并在 Visual Studio 中打开即可.这样,您就不必手动创建任何提取器和参数.

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天全站免登陆