File not supported error while uploading profile image file to IBM Connections using REST API - ibm-connections

I'm trying to upload a jpeg file for profile image using the Profiles REST API to IBM Connections_v5.0. I however get an error message "The type of the photo file you provided is not supported".
I'm however able to upload the same file directly using the Connections UI interface directly. I'm setting the MIME type correctly as "image/jpeg".
Also tried with GIF and PNG images but get the same error message.
Any pointers would be very helpful.
I'm just using FF restclient addon to fire a REST call. So basically doing a PUT on /profiles/photo.do?key=....
Content-Type is set as "image/jpeg" and the payload consists of the image data in binary (base 64) encoded.

The payload should just be the binary of the image, there is no need to Base64 encode it.

You should refer to Adding a Profile Photo
You need to use a Key (great stackoverflow post here)
If you know the key for a user's profile you can do the following:
key — This is generated by Connections itself during the population
process. It is used to define the users profile within the context of
Profiles and provides Connections with the ability to associate
content with a user when the users LDAP information has been altered.
It provides a separation of identity and helps facilitate user content
synchronization for Connections.
Once you have a key, you make the following request
URL: https://profiles.enterprise.example.com/profiles/photo.do?key=
b559403a-9r32-2c81-c99w-ppq8bb69442
METHOD: PUT
CONTENT-TYPE: image/png
input the binary content on the stream
you should be able to use "image/jpeg", "image/jpg", "image/png" or "image/gif"
If you have an error after the PUT method, you should add the SystemOut.log lines which are relevant.

Related

Add sample image in template header in whatsapp cloud API

I am doing a project using WhatsApp cloud API. I need to create a template with a media header. I have created a template with a media header without a sample image and it gets rejected. So I want to create a template with a sample image in Node JS.
Template with a media header
Add sample image for a template
curl -X POST "https://graph.facebook.com/v14.0/{whatsapp-business-account-ID}/message_templates
?name={template-name}
&language=en_US
&category=TRANSACTIONAL,
&components=[{
type:BODY,
text:{message-text}
},
{
type:HEADER,
format:IMAGE,
example:{header_handle:[{uploaded-image-file-url}]}
}],
&access_token={system-user-access-token}"
I want to add a sample image using Node JS (Not manually like the second picture).
header_handle requires a encrypted file upload provided by facebook.
This can be done by calling 2 apis.
First,
We have to create a session for the file to be uploaded.
For creating session refer this
After creating session, we will get session id to upload the original file to it.Response will look something like this:
{"id":"upload:MTphdHRhY2htZW50Ojlk2mJiZxUwLWV6MDUtNDIwMy05yTA3LWQ4ZDPmZGFkNTM0NT8=?sig=ARZqkGCA_uQMxC8nHKI"}
Second,We have to upload the file to
https://graph.facebook.com/v14.0/{above_id}
This will give a response something similar to
{"h":"2:c2FtcGxlLm1wNA==:image/jpeg:GKAj0gAUCZmJ1voFADip2iIAAAAAbugbAAAA:e:1472075513:ARZ_3ybzrQqEaluMUdI"}
Finally,
{header_handle:["2:c2FtcGxlLm1wNA==:image/jpeg:GKAj0gAUCZmJ1voFADip2iIAAAAAbugbAAAA:e:1472075513:ARZ_3ybzrQqEaluMUdI"]}
Should be added during the request to create template.
It worked for me.
See this for better understanding on how to do it.
The answer Provided by Aravindh is correct, you can follow This document from Meta to upload the Image you want.
Just make sure you use a supported type by WhatsApp API ( For WhatsApp Business Platform Cloud API , For WhatsApp Business Platform On-Premises API ) and the upload end point (file-type — The file's MIME type. Valid values are: image/jpeg, image/jpg, image/png, and video/mp4
)
Double Check if you are following exacly the types supported, for example in case of png, you need to set "file_type" to "image/png" no just "png" when creating the upload session.
I have tested it and it works for me.
Hope this helps

DocuSign: Unable to upload pdf Document via API

I'm trying to create a new envelope via api, but getting the following error message:
<errorDetails xmlns=""http://www.docusign.com/restapi"" xmlns:i=""http://www.w3.org/2001/XMLSchema-instance"">
<errorCode>UNABLE_TO_LOAD_DOCUMENT</errorCode>
<message>Unable to load the document. Unable to load Document(XXXXX.pdf).
Error: Value must be non negative. & vbLf & "Parameter name: Height</message>
</errorDetails>
Could you help with the problem? Not sure why it's happening.
Since the PDF worked when you uploaded it to DocuSign via the DocuSign web tool, the problem lies in how you uploaded it via the API.
When uploading via the API:
Set the fileExtension attribute to "pdf" or whatever the source format is. Eg "html", "docx", etc.
Set the documentBase64 attribute to the BASE64 encoded value of your source document.
I suggest you examine the code example for your preferred language to see how this is done:
C#,
PHP,
Java,
Node.js,
Python,
Ruby,
Curl (direct API)
Look at how scenario 1 or 2 reads and then uploads the source document to DocuSign.
If your document is larger than 15MBytes or so, you may want to upload to DocuSign using a binary transfer technique. To do so, see the examples' scenario number 10.

How to upload an mp4 (or other video) to Imgur using the API?

I am using the Imgur API to upload images to albums, as part of a Reddit bot. However, when I try to upload MP4 files I get an error: "File type invalid (1)". Uploading the exact same MP4 file using the website works just fine.
I am using this endpoint to upload the file: POST https://api.imgur.com/3/image
https://apidocs.imgur.com/#c85c9dfc-7487-4de2-9ecd-66f727cf3139
The above comment is no longer correct -- You can indeed upload an MP4 using Imgur API
import requests
url = "https://api.imgur.com/3/upload"
payload = {'album': 'ALBUMID',
'type': 'file',
'disable_audio': '0'}
files = [
('video', open('/path/to/Video.mp4','rb'))
]
headers = {
'Authorization': 'Bearer BEARERTOKENHERE'
}
response = requests.request("POST", url, headers=headers, data = payload, files = files)
print(response.text.encode('utf8'))
The above works for me and uploads successfully. Something to note though, I have not figured out how to make the upload tied to my account, or within a specific album. It seems to be ignoring the album_id field. In other words, despite using the Bearer token, it appears to be navigating the API "anonymously".
From the imgur Help site, located here and last updated 2 months ago:
https://help.imgur.com/hc/en-us/articles/115000083326-What-files-can-I-upload-What-is-the-size-limit-
File Types
If you need help learning how to upload on Imgur, check out this help
article. You can upload any of the following files: JPEG, PNG, GIF, APNG, TIFF, MOV (desktop website only), MP4 (desktop website
only)
Imgur doesn't currently support uploads in the following
formats: WEBM GIFV
Explicitly, MP4s are only currently supported as uploaded manually via the website directly.
Unfortunately, that means imgur does not support MP4 types through any method other than the Desktop site at this current time.
I agree with a comment above. Now it is works great. Even you can upload the video without authorization. Just using a POST method https://api.imgur.com/3/upload. Pass a video file in body with image key. That's all.
Example in Postman

Angular 6: Change Content-Type of template-generated page

Notice: This question is not about ANGULAR's HttpClient, but the document generated by a component's template.
I want to do an old trick for a simple, yet powerful MS EXCEL export: Generate an HTML document containing one single <table>, and serve it with "Content-Type: application/xls". The user's browser will forward the document to a locally installed MS EXCEL, which detects that this is not a "real" .xls, but HTML, and converts very nicely the HTML into a spreadsheet.
My approach to implement this is straigtforward: Add a route for path, say, "/export-xls", and a new component that gets the data and renders it in its template.
However I absolutely cannot find a way to set the "Content-Type" header in the response!? I envisage that in the "Routes" array I would set "contentType: 'application/xls'", but no way.
What is the easiest and best way to generate such a document from within ANGULAR?
You can solve your problem by doing following steps
create a file containing your table in your local file system and create a URL for that file using URL.createObjectURL method
send an http request to that file
intercept the request and add contentType: 'application/xls' to response headers
after receiving your file revoke the URL using URL.revokeObjectURL method and delete the file from your local file system
I am not sure if you can do this without the creation of physical file because you need an http request because of the response content type

How to upload audio file to s3 via api gateway?

I created an API in API Gateway to upload audio files to s3, the file is sending from local PC as multipart/form-data.
API integration request is shown below
In URL Path Parameters, added bucket as param and directly added the bucket name
When I try to upload the file I get an error response,
body: '<?xml version="1.0" encoding="UTF-8"?>\n<Error><Code>InvalidArgument</Code><Message>x-amz-content-sha256 must be UNSIGNED-PAYLOAD, STREAMING-AWS4-HMAC-SHA256-PAYLOAD, or a valid sha256 value.</Message><ArgumentName>x-amz-content-sha256</ArgumentName><ArgumentValue>null</ArgumentValue><RequestId>123445667788</RequestId><HostId>abcd/Jefgh2272vb/ghvsvds+gh+6273gdhsg+gdgshdshdsjdsj=</HostId></Error>'
What are the changes need to be done?
After some research, I found some very useful document
please go through this if you also face the same probem!!
added multipart/form-data to binary support in api.

Resources