There is a way to encode query params in base64 using insomnia rest client? - rest

I've been using insomnia for a while now and it has served me quite well. But when i need to make some more complex requests i don't know how to do it. Basically i need to make a GET request with a #request query param, that must hold a JSON encoded in base64. How can i do this inside insomnia? The template tag that does this job doesn't seem to work.

I was able to accomplish this by using the built in base64 function tag. Once I added this I was able to add a value to the tag that I wanted encoded (in my case an env var)

Related

How do I prevent mule from encoding the query-param?

In a HTTP request, I am adding a token as a query-param.
It seems that mule is encoding the value.
- If I add the parameter, mule will encode it in the way it is wrong.
- If I add already encoded parameter, mule will double encode it and therefore won't be usable anymore.
So the question is: Is there a way or a workaround to prevent mule from encoding the URL query-param?
Example of the parameter: {AES}ZEoksxIg484magPtWwNUUQ==;iT0kI2HsqGkh%2Bdc2baW2B4dNR2vouKkWQsDTdbMP8us=
My colleague found a workaround for this, so I'm sharing it here.
Apparently, you can set a variable before the HTTP request and add the manually encoded value. Let's call it ourTokenVariable In my example above that would be %7BAES%7DZEoksxIg484magPtWwNUUQ%3D%3D%3BiT0kI2HsqGkh%252Bdc2baW2B4dNR2vouKkWQsDTdbMP8us%3D
After that, you can use this newly created variable directly in the url path. For example: /example/someapi?someToken=[#flowvars.ourTokenVariable]
This way you don't need to use uri-param or query-param anymore (where mule is double encoding the value). The value will be taken 'as is'.

Base64 Encoding on ng-file-upload

When a file is selected or dropped, is it automatically converted to Base64 encoding?
I need to be able to take files, convert them to strings then pass them into POST requests to our backend.
Is ng-file-upload already converting the file? Or is this something I need to manually do by calling either the:
Upload.base64DataUrl(files).then(function(urls){...});
or
Upload.dataUrl(file, boolean).then(function(url){...});
methods?
I can post the relevant code but this seems relatively straightforward. Thanks for the help!

How to build a Uri in Spray?

I would like to make a simple GET request via Spray with a few query parameters
Get("http://localhost/user?email=abc+a#abc.com")
However + means a space in application/x-www-form-urlencoded content resulting the call to http://localhost/user?email=abc a#abc.com (with a space instead of plus sign).
I could use a non-Spray java.net.URLEncoder to encode the URL before passing it to the GET request however I doing this every time seems like a hack.
Is there a Spray way of applying query parameters and encoding them?
Uri("http://localhost/").withQuery(Map("email"->"abc+a#abc.com")) is a nice way to construct a Uri but it doesn't encode the params as well...
Actually Uri("http://localhost/").withQuery(Map("email"->"abc+a#abc.com")) works fine as it encodes the special symbols.
However, Uri("http://localhost/").withQuery("email=abc+a#abc.com") doesn't.
I use java.net.URLEncoder. I believe that is the accepted method.
It would be nice if that happened automatically!

Gattling stress tool to parse json out of JSP

I have a spring service which renders JSP page. Spring controller sets JSON data in a request attribute, which i use in my JSP. Can anyone tell how can i parse this JSON data. I know if my web service response was a plain json , i can parse using jsonPath. But in my case JSON is a part of JSP. So I am kinda stuck.
You mean that your JSON is inside your HTML, probably in a Javascript variable?
And I guess using a regex to retrieve the elements your interested in is not enough and that you really want the JSON string?
If so, you can first use a regex check in order to extract your JSON content from your HTML. Beware that if your JSON string is on several lines, you might have to enable some regex features such as multiline or dotall. See
Then, you can transform your regex output into a JSON tree, using the check transform step. There, you can parse the JSON string with the engine of your choice. Gatling ships with json-smart.
Another solution is to build your own check. The procedure for Gatling 2 has been described in this thread on Gatling's Google Group.

BigCommerce API Update Order with PUT

I need to update an order which is done via PUT method passing the order id as part of the https url string and a single parameter, the status_id.
https://mystore.mybigcommerce.com/orders/12345.json
I have tried several methods to pass the status_id value but no matter what I try "status_id=12" or formatted as JSON "{"status_id": 12,}" I always get the same response:
[{"status":415,"message":"The specified input content type is not valid."}]
I have also tried as a POST request passing the JSON or XML code as raw data but that method is not supported.
How am I supposed to pass that field=value pair? can I embed it in the url string?
I also tried it but it wouldn't work for me.
Any ideas?
In case you are wondering I am doing it within FileMaker with TROIUrl plugIn, not a very popular technology, but the GET method retrieving orders works like a charm
TURL_Put( ""; $url ;"status_id=12") (I have also tried other FM plugIns to no avail)
Don't get too caught up in the Filemaker part, I don't expect many people out there to be familiar with BigCommerce and Filemaker. I just need a generic answer.
Thanks
Commandline tool curl is worth a try. It supports put and https.
Mac OS X: curl already installed, call from FileMaker via AppleScript do shell script.
Windows: must be installed, call via Powershell.
It works for me using { "status_id": "3" } which means you probably need to put quotes around the actual number.
Also, it is a PUT operation and application/json which is part of the request content.
The error message received by the OP:
[{"status":415,"message":"The specified input content type is not valid."}]
Is saying that he did not supply the 'Content-Type' header in his request or that the header supplied is for a content type that is not allowed. For the OP's case using JSON he would need to include the header:
Content-Type: application/json
in his HTTPS request. This description can be found along with those of the other status codes you may see here:
https://developer.bigcommerce.com/api/status-codes