Using the SharePoint REST API, I can download a file from a Document Library no issue. But now I want to download an Attachment from a List.
I can find my list, and I can list my Attachments with the SP or Graph API no issue. example: https://learn.microsoft.com/en-us/graph/api/listitem-list?view=graph-rest-1.0&tabs=http or a /_api/web/lists/getbytitle('ListName')/items(1)/AttachmentFiles give me a nice list of my Attachment URLs, but not the file itself.
If I try a GET with Authorization on the URL I get a 401. But If I just paste the URL in a browser it downloads.
I have seen its possible with SP Powershell, but I am not able to use that in this solution.
I am not able to find a API to download it. Is this possible?
Bonus points if I can just get it as a Base64 string.
You have to loop on the attachments and append /$value to retrieve the data.
You can find more details in Microsoft documentation: https://learn.microsoft.com/en-us/sharepoint/dev/sp-add-ins/working-with-folders-and-files-with-rest#working-with-files-attached-to-list-items-by-using-rest
GET https://{site_url}/_api/web/lists/getbytitle('{list_title}')/items({item_id})/AttachmentFiles('{file_name}')/$value
Authorization: "Bearer " + accessToken
Accept: "application/json;odata=verbose"
Related
I'm getting attached PDF to invoice in Zoho books. I will use GET request (using invokeUrl or postUrl functions). I'm getting result already in Postman:
https://gyazo.com/e3a74ff1e5051928ddb162c0e01dbdd8
I'm getting content of PDF in binary format. But I'm stumbling what to do the next. I need to put this pdf now to any shared resource: Zoho Workdrive, Google disk, dropbox etc. I don't know how to do this in Deluge easier. It should be sharable resource (everyone should have access to this link and can download it).
I'm looking for documentation of Zoho API, found a lot examples in other languages like JS. Expect to find optimal (easy and fast as possible) solution in Deluge.
downloadFile = invokeurl
[
url :"https://books.zoho.com/api/v3/invoices/3675398000000085014/attachment"
type :GET
connection:"invoicescom"
];
info "downLoadFile = " + downloadFile;
uploadResponse = zoho.workdrive.uploadFile(downloadFile,"xxxxxxxxx","book1.pdf",FALSE,"workdrivecon");
info "uploadResp = " + uploadResponse;
I'm trying to upload an image as profile picture using WhatsApp Cloud API *.
After creating an application using WhatsApp Cloud API I'm not allowed to access neither using the regular application nor using Business Application. It says something like "try again in one hour". So I have to implement everything using the API.
After reading the docs and importing Postman Endpoints I found the one called Business Profiles > Update Business Profile
https://graph.facebook.com/{{Version}}/{{Phone-Number-ID}}/whatsapp_business_profile
It has a field "profile_picture_url"and I have tried POSTing media https://graph.facebook.com/{{Version}}/{{Phone-Number-ID}}/media and then with the given ID y used https://graph.facebook.com/{{Version}}/{{Media-ID}} to get the URL but it didn't work. The rest of the information is updated successfully
{
"messaging_product": "whatsapp",
"address": "",
"description": "Simple Bot",
"email": "...#gmail.com",
"websites": [
"https://..."
],
"profile_picture_url": "https://lookaside.fbsbx.com/..."
}
However if I try to send someone using the ID and the endpoint https://graph.facebook.com/{{Version}}/{{Phone-Number-ID}}/messages it works fine.
And if I use Download Media Content with the URL in Postman it works fine too.
I don't know if I have misunderstood something or if it can't be done using the API.
It is mentioned in the Cloud API Documentation:
profile_picture_url (Optional): URL of the profile picture generated from a call to the Resumable Upload API.
But, i got it working using profile_picture_handle instead of profile_picture_url. So how do we get the profile_picture_handle?
Prerequisite:
Graph API token here. Or use your WhatsApp Cloud API token.
App ID, go Apps > Your App > Settings (sidebar menu) > Basic
Update Photo Profile:
Call POST https://graph.facebook.com/v14.0/{{appId}}/uploads?access_token={{token}}&file_length={{fileSizeInByte}}&file_type=image/jpeg
Save the session id you got, upload:XXXXXX?sig=XXXXXX.
Call POST https://graph.facebook.com/v14.0/{{sessionId}}, with the headers: Authorization=OAuth {{token}}, file_offset=0, Host=graph.facebook.com, Connection=close, Content-Type=multipart/form-data, and include your image file in the request body with type binary. If you using Postman, see image below (This is what I missed for hours).
Save the handle result you got, 4::XXX==:XXXXXX.
Finally, call POST https://graph.facebook.com/{{Version}}/{{Phone-Number-ID}}/whatsapp_business_profile, with json request body: {"messaging_product": "whatsapp", "profile_picture_handle": "4::XXX==:XXXXXX"}
That's it, You can check the profile picture.
The last step you have to add your taken by selecting "Bearer" or else it will give you error. I had hard time on the last ones, do all the steps and then go to the following link and it should help.
https://web.postman.co/workspace/My-Workspace~a4ddb3b8-02a3-4132-8384-66e63e149b7b/request/22958165-506a0542-c845-41ac-b3fb-b8209fd6f53b
I'm trying to use a logicapp to get the content of an email and post it to slack. By content I mean:
the body of the email and other elements like From:, Subject:
any attachment in the email (which usually are binary like PDF, Excel, image)
the email itself saved in a blob as .eml file
Slack chat.postMessage API works without any problem to send any text element. This API has some attachment argument but doesn't seemto be designed or binary files (or not for files at all, only strings)
I've tried slack files.upload one but couldn't figure out the syntax, especially the syntax using a regular HTTP POST. Could find examples online using curl, Python, JS and C# SDK but I don't know how to translate them to HTTP POST just like I do with chat.PostMessage
I've tried the API on SOAP UI, using file as argument as per the documentation, and I've used it in different sections: in the header, in the body, and using the Attachment Tab, none of the work and always the same error message : no_file_data
Unfortuatelly slack documentation lacks of details. Here's what it says about files.upload:
You must provide either a file or content parameter.
The content of the file can either be posted using an enctype of multipart/form-data (with the file parameter named file), in the usual way that files are uploaded via the browser, or the content of the file can be sent as a POST var called content. The latter should be used for creating a "file" from a long message/paste and forces "editable" mode.
In both cases, the type of data in the file will be intuited from the
filename and the magic bytes in the file, for supported formats.
I could use alternatives like just saving the attachments in blobs and use Azure functions to send the file, but I want to understand what's the limitations before changing the method.
Any clue?
I'm using Sharepoint v1.0 API and want to retrieve a file by it's document id. I can't find any documentation on how to retrieve a file this way. If I use the URL:
https://xxxxxxxx.sharepoint.com/sites/xxxxxxx/_layouts/15/DocIdRedir.aspx?ID=MLVDK4UWQQ8B-763006743-3089
The response is a 401 so direct calls don't work. I can query the API but I don't know how to translate the above URL to an URL I can use with that API. The URL should be something like:
https://xxxxxxxx.sharepoint.com/sites/xxxxxxx/_api/
What is the correct way to retrieve the document using the API? I've tried:
https://xxxxxxxx.sharepoint.com/sites/xxxxxxx/_api/search/query?refinementfilters=DlcDocId:equals("MLVDK4UWQQ8B-763006743-3089")
https://xxxxxxxx.sharepoint.com/sites/xxxxxxx/_api/search/query?DlcDocId='MLVDK4UWQQ8B-763006743-3089'
https://xxxxxxxx.sharepoint.com/sites/xxxxxxx/_api/Web/GetFolderByServerRelativeUrl('Shared
Documents')/Files
https://xxxxxxxx.sharepoint.com/sites/xxxxxxx/_api/Web/GetFileByServerRelativeUrl('_layouts/15/DocIdRedir.aspx?ID=MLVDK4UWQQ8B-763006743-3089')/Versions
Try to use DocId=MLVDK4UWQQ8B-763006743-3089 in search rest api:
https://xxxxxxxx.sharepoint.com/sites/xxxxxxx/_api/search/query?querytext='DocId=MLVDK4UWQQ8B-763006743-3089'
Reference:
Search By Document ID In SharePoint 2013
I know that is not an official API endpoint you are maybe looking for but if you want to download the document with SharePoint url you may try to use the download.aspx like
https://xxxxxxx.sharepoint.com/sites/xxxxx/_layouts/15/download.aspx?UniqueId=MLVDK4UWQQ8B-763006743-3089
I hope this will be of any help
I have to perform testing through selenium webdriver(java) on Site analytics of a website. All the attributes, values are sent to the analytics toold via URL header request. I would like to capture the request alone so that I can perform my manipulations and extract the attributes and their values.
I tried BrowserMob tool. It's getting me the entire traffic in the form of HAR file. is there a way to extract the request alone?
I tried server.setCaptureHeaders(true); but it didn't help much as I see a whole bunch of URLs in the HAR. I'm interested in only one that is sent to the analytics website. There is a URL thats sent as a request behind the scene. Few analytics plugin are able to exactly get the request URL and extract the attribute values but I can't automate through those plugins.
Or is there a way to rip off only certain requests from HAR?
BMP is a great tool. You can only create a new har before the request is sent and read it after this. You can iterate through the dict it returns and find the request you need