Spail
Spail

Reputation: 703

Calculating dynamic value from request body parameters in Paw

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]):

enter image description here

test_var equals to 'test_variable'

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

enter image description here

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

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

What's wrong?

Upvotes: 1

Views: 872

Answers (1)

Micha Mazaheri
Micha Mazaheri

Reputation: 3481

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.

Set a reference to another part of the request body in Paw

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

Referencing a hash in a request in Paw

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

Upvotes: 2

Related Questions