vscode-restclient
vscode-restclient copied to clipboard
could you please add some before/after script ?
My server API is need RSA sign verify,How can I sign my request body before send request to server?
If I could execute script before send request to server,I can sign it.
@kingwrcy This is in my plan. Thanks for your suggestion.
Thanks,it also prevent me to use fully without this function.
@kingwrcy This is in my plan. Thanks for your suggestion.
I think it will be a great Release.Would you tell me when it release. Thank you for your reply!
as a workaround, i converted my REST request to python (using the tooling provided), and simply pre-pended the necessary script, which for me was to deflate my body, in python
worked a treat, i'm sure there will be a better solution in the future... 🙂
This is currently the only thing preventing my migration from Postman.
I need this feature badly, too. Is it in the plan?
@Piean still under investigation
This PR solves it for me. Would it work in your case @Piean ? https://github.com/Huachao/vscode-restclient/pull/532
@jnorkus I think it's still a bit different, PR #532 provides the ability that executes the Shell
command, this issue mainly focuses on the ability that we can do some kind of custom works before request and/or after response. And this feature can even expose some JavaScript APIs for extension users to do what they want as other REST tools like Postman
.
And I am considering your PR to add it into my extension. Good Job @jnorkus
I understand that @Huachao but the OP and possibly @Piean might solve their issue with my solution. In my case I needed to generate an auth token and I thought a before script was the way to go. But $eval actually works fine and is much more simple.
I understand that @Huachao but the OP and possibly @Piean might solve their issue with my solution. In my case I needed to generate an auth token and I thought a before script was the way to go. But $eval actually works fine and is much more simple.
One of the parameters of my request is that it needs to be calculated by MD5 with other parameters.
@Piean I don't have details on your use case and what exactly you need to do but this is what I currently use on my fork:
"Authorization": "Bearer {{$eval node generate_token.js %token}}"
generate_token.js
is a custom node script that accepts an input (%token - read from vscode settings) and returns a generated auth token. Could something similar work for you?
@jnorkus Your solution is very close to what I am looking for, thank you very much!
What do you think about resolving file variables instead of vscode settings variables? This would provide more flexability. This might be useful in scenarios where you need to pass the result of an previous eval. You would still be able to assign a vscode setting to a file variable which in turn gets referenced in the eval.
For example I am not able to implement the bitfinex headers without passing file variables to the eval: https://docs.bitfinex.com/docs/rest-auth
@jnorkus My case is different from yours, for example:
POST host/url HTTP/1.1
Content-Type: application/json
{
"param1": "value1",
"param2": "value2",
"sign": $MD5("param1" + value1 + "param2" + value2)
}
The "sign" is all of other parameters join by parameter name and value one by one, then MD5. Your %token is a file variable, It is constant. But my inout for the expression is changed with request parameters
@Huachao When will this feature be released. I wish I could have used this feature earlier.
as a workaround, i converted my REST request to python (using the tooling provided), and simply pre-pended the necessary script, which for me was to deflate my body, in python
worked a treat, i'm sure there will be a better solution in the future... 🙂
@m1nkeh i was wondering on the home page it says "Generate code snippets for HTTP request in languages like Python, JavaScript and more" but i could not find any examples of that, is it something similar you were talking about ? could you please provide an example of what you did ? Thanks
Was this feature implemented?
look forward to this feature!
look forward to this feature too!
look forward to this feature!
@Huachao
作者你好,想问一下。这个插件还会维护么? 这个功能后续还会加进去么?
感谢!
It's still in the plan? look forward to this feature for a long long time, more than 4 years .