从Paw中的请求正文参数计算动态值 [英] Calculating dynamic value from request body parameters in Paw

查看:261
本文介绍了从Paw中的请求正文参数计算动态值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的API中有一些方法,因此需要使用请求参数的哈希值进行签名.假设我的请求中有三个参数:第一",第二"和变量",这是通过环境变量设置的.我需要添加第四个参数'hash',它等于MD5([first] [second] [variable]):

I have methods in my API that have so be signed with hash of request parameters. Let's say I have three params in my request: 'first', 'second' and 'variable', which is set from environment variable. I need to add fourth parameter 'hash', which is equal to MD5([first][second][variable]):

test_var等于'test_variable'

test_var equals to 'test_variable'

为此,我使用从当前请求中读取的Request Parsed Body参数来计算MD5.我收到警告,由于自我依赖性,无法使用这些参数,并且该请求的主体为空,但MD5的计算正确:MD5(firstParamsecondParamtest_variable)= 09f8669986f4152487da543e12e1e393

To do this I calculate MD5 with Request Parsed Body params, which are read from current request. I get warnings that these params cannot be used because of self-dependency, and that request has an empty body, but MD5 is actually calculated correctly: MD5(firstParamsecondParamtest_variable) = 09f8669986f4152487da543e12e1e393

但是,当我发送此请求时,哈希值以某种方式更改,并且不再正确:

But, when I send this request hash value changes somehow, and is no longer correct:

first = firstParam& second = secondParam& variable = test_variable& hash = d3a0cc12d51633f07820b9d5ff167126

first=firstParam&second=secondParam&variable=test_variable&hash=d3a0cc12d51633f07820b9d5ff167126

怎么了?

推荐答案

它已在较新版本的Paw中修复.您可以简单地按照问题中的建议进行操作.右键单击并选择Request> Request Parsed Body.

It has been fixed in newer versions of Paw. You can simply do like suggested in the question. Right-click and pick Request > Request Parsed Body.

添加您需要的所有引用,您将拥有想要的哈希值:

Add all the references you need, and you'll have the wanted hash:

现在,您已将前三个参数的MD5串联在一起(没有错误报告).

You now have the MD5 of the three first params concatenated (no error reported).

这篇关于从Paw中的请求正文参数计算动态值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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