SoftLayer API - retrieve invoices - ibm-cloud

I am using SoftLayer_Billing_Invoice::getPdfDetailed to retrieve the latest invoice, but the file does not seem to be a binary file. How to decode that file and get it opened.

that depends on if you are using a Softlayer client or if you are using simple REST request, using a simple REST request the response is encoded in base64 and you must decode it (you could try using this online tool http://www.motobit.com/util/base64-decoder-encoder.asp and export the result in a file)
Now if you are using a Sofltyer client such as Softlayer's Python or Ruby client they are using xmlrpc for the request and they uses its own data type to store that data you can see an example about that using the Python client here How to get "PDF" file from the binary data of SoftLayer's quote?
Regards

Related

Data Factory can't download CSV file from web API with Basic Auth

I'm trying to download a CSV file from a website in Data Factory using the HTTP connector as my source linked service in a copy activity. It's basically a web call to a url that looks like https://www.mywebsite.org/api/entityname.csv?fields=:all&paging=false.
The website uses basic authentication. I have manually tested by using the url in a browser and entering the credentials, and everything works fine. I have used the REST connector in a copy activity to download the data as a JSON file (same url, just without the ".csv" in there), and that works fine. But there is something about the authentication in the HTTP connector that is different and causing issues. When I try to execute my copy activity, it downloads a csv file that contains the HTML for the login page on the source website.
While searching, I did come across this Github issue on the docs that suggests that the basic auth header is not initially sent and that may be causing an issue.
As I have it now, the authentication is defined in the linked service. I'm hoping that maybe I can add something to the Additional Headers or Request Body properties of the source in my copy activity to make this work, but I haven't found the right thing yet.
Suggestions of things to try or code samples of a working copy activity using the HTTP connector and basic auth would be much appreciated.
The HTTP connector expects the API to return a 401 Unauthorized response after the initial request. It then responds with the basic auth credentials. If the API doesn't do this, it won't use the credentials provided in the HTTP linked service.
If that is the case, go to the copy activity source, and in the additional headers property add Authorization: Basic followed by the base64 encoded string of username:password. It should look something like this (where the string at the end is the encoded username:password):
Authorization: Basic ZxN0b2njFasdfkVEH1fU2GM=`
It's best if that isn't hard coded into the copy activity but is retrieved from Key Vault and passed as secure input to the copy activity.
I suggest you try to use the REST connector instead of the HTTP one. It supports Basic as authentication type and I have verified it using a test endpoint on HTTPbin.org
Above is the configuration for the REST linked service. Once you have created a dataset connected to this linked service you can include it in you copy activity.
Once the pipeline executes the content of the REST response will be saved in the specified file.

Multipart upload binary content with OneDrive Rest APIs

As per the API documentation here I formed my request with postman as follows:
. This is working fine.
But when it comes to binary content(encoded in base64 format), it uploads the file but that is not previewed when I try to open the same on OneDrive.
File gets uploaded successfully but not previewable.
What am I missing here? Any suggestions?
OneDrive doesn't support Content-Transfer-Encoding when using the multi-part upload method. In this case, we're ignoring the header (that seems like a bug) and just storing the base64 encoded data in the file stream (without decoding it).
You'll have to upload the raw bytes as the second part of the request, without any content-transfer-encoding, to have this work.
Since it seems like you are just uploading a file and not trying to set any custom metadata while doing it, you're better off using one of the other upload methods, like PUT or createUploadSession
Drive does not store the image in the base64 format it stores it in binary. you can directly select the image using postman and can upload as binary with the multipart request
Here is the link for adding blob in the postman
How to upload images using postman to azure blob storage

Restygwt download byte[]

I have only an array of byte on the client side.
Another server send me JSON
{
report - byte[]
}
I am looking for ways to save byte [] in browser
Send them to server or I can download from client side.
I can not find any solution at all.
So my question "Is it possible to save with restygwt byte [] an how???"
It is not possible to save the file directly from Resty.
https://github.com/resty-gwt/resty-gwt/issues/341
The most common workarounds to download files using AJAX are not using AJAX at all.
You can simply change the URL (using window.location) or (using javascript) create or;
create a form (using JS) and post that form.
In my projects, I simple create a URL to my REST endpoint attaching any query parameters needed and use it as the href to a link.
For instance, if your RestyGwt endpoint points to /entity/1/bytes
just do
new Anchor("Download", "/entity/1/bytes");
your endpoint must produce a downloadable file type say:
#Produces("text/txt")

Get non file body from multipart/form-data using AWS API Gateway and Lambda

I am trying to get the form data from a multipart/form-data POST to my ASW Lambda web service via API Gateway.
The HTTP POST has Content-Type "multipart/form-data" and body that is URL encoded. File data is also sent in this post (hence the multipart, I guess).
The web service needs to integrate with a thirdparty service, so changing the format of the POST isn't really an option.
I have seen this thread talking about converting the URL encoded data to JSON object for use in Lambda, but this doesn't do the trick.
I have also tried setting the Integration Request -> Mapping Templates for content type multipart/form-data to Input passthrough. This didn't help either.
I did come across another question about uploading a file using multipart/form-data, but since I'm not interested in the file, just the body, that answer didn't help.
Below find screenshot (sorry) of the captured post via runscope.
If the goal is to use Lambda, you'll need to pass valid JSON to the function. Currently there isn't a way to JSON-ify data inside Api Gateway that comes in as non-JSON data.
Our short term fix (on our backlog) is to provide a variable in the mapping templates to grab the raw input of the request. That way you could do a simple JSON conversion using a template like:
{
"body" : "$input.body"
}
or something like that.
Check out the mapping template reference for more info: http://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-mapping-template-reference.html
Edit 4/7 - feature has been released as $input.body

passing arrays with advanced rest client chrome plugin

I'm trying out chrome-extension advanced rest client app, but when I send something like:
http://myDom:34234/my/path/method?param=["{a-guid}"]
the actual parameter arrives on the server as "[\"{a-guid}\"]" how do I get it to send the array as an array rather than a string?
Proper URL for this request should looks like:
http://myDom:34234/my/path/method?param=%5B%22%7Ba-guid%7D%22%5D
All URLs must be encoded.
In the app you can expand URL panel and under "Query parameters" section encode values to proper form.
it depends on your server implementation (e.g. php, c#, rails, javascript, python, etc).
all headers arrive on the server as a string. it's up to the application to parse that string into a native object (e.g. an array) in that language.
in the php world, here's the code we use:
parse_str(file_get_contents('php://input'), $args);
update:
based on your comment below i suggest you use new JavaScriptSerializer.Deserialize(jsonString)
You need System.Web.Extensions dll for the same and import the following namespace.
Namespace: System.Web.Script.Serialization
for more info MSDN