Discord API can't send attachments from url - discord

I can't send attachments via Discord API
Type: Post
URL: https://discord.com/api/channels/[ID]/messages
Data:
"embeds": [{
"description": "hi",
}],
"attachments": [{
"id": 0,
"url": "https://logos-world.net/wp-content/uploads/2021/08/Among-Us-Logo.png",
}]
(All is working, when i remove "attachments")
I tryed Googling,searching Discord API

Related

Fetch with Custom Headers inside React Server Component

Is it possible to make a fetch request with custom headers inside a React server component? I'm trying access a video stream url with custom headers.
This is the API I'm trying to stream the video from:
{
"status_code": 200,
"message": "Episode found",
"data": {
"anime_id": 5,
"number": 100,
"title": "Episodio 100: La catena invisibile",
"video": "https://cdn2.dreamsub.me/fl/eyeshield-21/100/SUB_ITA/480p?token=73UQpt6f00zRQWyDUeGbefNcrpi8qYA3Pk310BoXZi4I3MQzUSkia026Kf9rxnYV",
"video_headers": {
"host": "cdn.dreamsub.cc",
"referer": "https://cdn2.dreamsub.me/fl/eyeshield-21/100/SUB_ITA/480p?token=73UQpt6f00zRQWyDUeGbefNcrpi8qYA3Pk310BoXZi4I3MQzUSkia026Kf9rxnYV"
},
"quality": "480",
"format": "mp4",
"locale": "it",
"is_dub": false,
"id": 485
},
"version": "1"
}

How to add SSO to an azure bot on microsoft teams

Followed steps documented to enable bot sso
Created a bot.
Added Microsoft Teams under Channels.
Under Configuration added the messaging endpoint. e.g. (https://myproxy.proxyapp.com/teams/app/activity).
Generated a client secret for the Microsoft app id.
Added "https://token.botframework.com/.auth/web/redirect" as the Redirect URI for Web platform under Authentication for my Microsoft App.
Under API Permissions for my Microsoft App added "email offline_access openid profile". "User.Read" was available by default.
Under Expose an API added "api://botid-{Microsoft app id}". Added scope "access_as_user". Added web (1fec8e78-bce4-4aaf-ab1b-5451cc387264) and desktop (5e3ce6c0-2b1f-4285-8d4b-75ee78787346) client applications.
In the Manifest file for my Microsoft app updated "accessTokenAcceptedVersion": 2.
For my bot added an OAuth Connection as below
Created an app on Microsoft Teams and associated my Micorsoft App Id as the bot id. Attached is the manifest for my Microsoft Teams app.
When I install this app to Microsoft Teams the bot is shown in the chat tab which is expected. Further the document says as a 1st step
"The bot sends a message with an OAuthCard that contains the tokenExchangeResource property.". How can I achieve this?
When I type "Hi" for the very 1st time on the bot I receive the below JSON at my messaging endpoint
{
"text": "hi",
"textFormat": "plain",
"attachments": [
{
"contentType": "text/html",
"content": "<div>hi</div>"
}
],
"type": "message",
"timestamp": "2021-10-05T18:27:21.5454867Z",
"localTimestamp": "2021-10-05T23:57:21.5454867+05:30",
"id": "1633458441515",
"channelId": "msteams",
"serviceUrl": "https://smba.trafficmanager.net/in/",
"from": {
"id": "29:1kR5UGDG5iTFhsVadKAadeYuzsLEhMYK_YFxb7_Y62nAilJVLIMiPtC8oLrGGyK7wZTaFc8-jlVxJq3q0bpoBMw",
"name": "Ashish Sood",
"aadObjectId": "3836************************be046"
},
"conversation": {
"conversationType": "personal",
"tenantId": "1734*************************bb8ecf",
"id": "a:1xMOdsbv02hfl2J4GUGA7-WemaLGCOxFlzsSNcQ9StjIMAAKn64tJ0zxKk25b02NMTl3rc7nbNffMZGXVYfraNIDKnptC01oeLRv7Ngh2WMCyOrmBT2KaDleQXSU2s4MY"
},
"recipient": {
"id": "28:18c9**********************02b9",
"name": "NOW_Virtual_Agent_SSO_Bot"
},
"entities": [
{
"locale": "en-GB",
"country": "GB",
"platform": "Mac",
"timezone": "Asia/Calcutta",
"type": "clientInfo"
}
],
"channelData": {
"tenant": {
"id": "1734************************b8ecf"
}
},
"locale": "en-GB",
"localTimezone": "Asia/Calcutta"
}
How do I use this JSON to complete the 6 steps mentioned at
add sso authentication
Microsoft Teams App manifest.json
{
"$schema": "https://developer.microsoft.com/en-us/json-schemas/teams/v1.11/MicrosoftTeams.schema.json",
"manifestVersion": "1.11",
"version": "1.0.0",
"id": "9a83***************************177d",
"packageName": "com.microsoft.teams.devapp",
"developer": {
"name": "SSO Bot App",
"websiteUrl": "https://www.teams.com",
"privacyUrl": "https://www.teams.com/privacy",
"termsOfUseUrl": "https://www.teams.com/termsofuse"
},
"icons": {
"color": "color.png",
"outline": "outline.png"
},
"name": {
"short": "SSO Bot App",
"full": "SSO Bot App"
},
"description": {
"short": "SSO Bot App",
"full": "SSO Bot App"
},
"accentColor": "#FFFFFF",
"staticTabs": [
{
"entityId": "conversations",
"scopes": [
"personal"
]
},
{
"entityId": "about",
"scopes": [
"personal"
]
}
],
"bots": [
{
"botId": "18c9**********************02b9",
"scopes": [
"personal"
],
"supportsFiles": true,
"isNotificationOnly": false
}
],
"permissions": [
"identity",
"messageTeamMembers"
],
"validDomains": [
"token.botframework.com"
],
"webApplicationInfo": {
"id": "18c9**********************02b9",
"resource": "api://botid-18c9**********************02b9"
}
}
We ran into the same issue and spit through the nodejs/.net bot framework code to find what JSON is exactly sent for an OAuth card. We ended up with the follow JSON:
{
"attachments": [
{
"content": {
"connectionName": "<name of your sso oauth connection>",
"text": "<some text, is not shown>",
"tokenExchangeResource": {
"id": "<some random id, for validation in invoke request>"
}
},
"contentType": "application/vnd.microsoft.card.oauth"
}
],
"channelId": "msteams",
"conversation": {
"id": "<conversation ID>"
},
"from": {
"id": "<your conversation bot id>"
},
"recipient": {
"id": "<conversation user id>"
},
"serviceUrl": "<service URL of conversation>",
"type": "message"
}

how to Bring pre-created custom field from docusign Sandbox to envelope using REST api?

I have created some custom fields in my Docusign Sandbox, but I'm unable to bring them onto my envelope while sending it for eSignature.
I want Docusign custom fields to write back data to Salesforce fields when signer has entered some value and signed the document
I have tried it with the below JSON. The envelope is created but I can't find the custom fields
{
"emailBlurb": "String content",
"emailSubject": "String content",
"enableWetSign": "true",
"recipientsLock": "false",
"status": "sent",
"customFields": {
"listCustomFields": [{
"name": "String content",
"required": "false",
"show": "true",
"value": "String content",
"listItems": [
"String content"
]
}],
"textCustomFields": [{
"name": "Insurance Expiration",
"required": "false",
"show": "true",
"value": "012/02/2111"
}]
},
"templateId": "152bacc1-9d5d-4243-9fe4-9dafe0785164",
"templateRoles": [{
"email": "r00ranjit#gmail.com",
"name": "ranjit",
"roleName": "CFO",
"emailNotification": {
"emailSubject": "String content",
"emailBody": "String content"
},
"tabs": {
"textTabs": [{
"tabLabel": "String content111",
"name": "String content1",
"value": "String content"
}]
}
}],
"emailSettings": {
"bccEmailAddresses": [{
"email": "r00ranjit#gmail.co"
}]
},
"compositeTemplates": [{
"inlineTemplates": [{
"sequence": "1",
"customFields": {
"textCustomFields": [{
"name": "Insurance Expiration",
"required": "true",
"show": "true",
"value": "06/06/2010"
}]
},
"recipients": {
"signers": [{
"name": "Millard Fillmore",
"email": "ranjit.r#attinadsoftware.com",
"recipientId": "1",
"routingOrder": "1"
}]
}
}]
}]
}
When you send from Salesforce, there is information passed to document (such as the SourceID and Source Object Type), that DocuSign Connect will attempt to match to a record to process a request to push the data back into Salesforce.
When you send from the API you need to provide this data in order for Salesforce to know where you want information published back.
DocuSign API how to sync tags in template with Salesforce fields
https://salesforce.stackexchange.com/questions/92069/how-to-set-docusign-envelope-external-source-id-field-via-docusign-api
Those should help.

api access to cloud drives attachment (url)

Can we get attachment URL trough podio API if we use a cloud drive ex: onedrive or dropbox?
Unfortunately offical export function doesn't containt that URLs.
Can we reach this data through API?
thank you
You can get a URL for a Dropbox file, although it is a shortened URL. Here's how I did it:
I attached a Dropbox file to an item. First, I looked up the ID of the associated item (https://developers.podio.com/doc/items/get-item-22360) and used the API to retrieve the item's details. Within the response JSON you will find a list of files that looks something like this (some details shown below are redacted to protect the innocent):
"files": [
{
"mimetype": "application/pdf",
"perma_link": null,
"hosted_by": "dropbox",
"replaces": [
],
"description": null,
"hosted_by_humanized_name": "Dropbox",
"presence": null,
"created_via": {
"url": null,
"auth_client_id": 1,
"display": false,
"name": "Podio",
"id": 1
},
"created_by": {
"user_id": REDACTED,
"name": "REDACTED",
"url": "https://podio.com/users/REDACTED",
"type": "user",
"image": {
"hosted_by": "podio",
"hosted_by_humanized_name": "Podio",
"thumbnail_link": "REDACTED",
"link": "REDACTED",
"file_id": REDACTED,
"external_file_id": null,
"link_target": "_blank"
},
"avatar_type": "file",
"avatar": REDACTED,
"id": REDACTED,
"avatar_id": REDACTED,
"last_seen_on": "2016-10-31 20:56:58"
},
"thumbnail_link": null,
"created_on": "2016-10-31 20:59:41",
"link": "https://db.tt/N3sW8SwL",
"file_id": REDACTED,
"rights": [
"view",
"download",
"delete",
"update"
],
"push": null,
"external_file_id": "/Get Started with Dropbox.pdf",
"link_target": "_blank",
"size": null,
"name": "Get Started with Dropbox.pdf"
}
]
I believe the field you are looking for is "link," but it appears to contain a shortened URL instead of the full-length URL.

Different response on similar requests Gmail API

I'm trying to handle the response object from Gmail API with getting attachments from certain messages:
In my Gmail account i have 2 Labels:
Label_1
Label_2
both messages get daily reports from different web services and im using the Gmail API to first get a list of messages while im filtering a message with a Label and a query search string (q field) which contains a certain date (this is how i get only one message when i request a list)
with the response object Im able to get the message ID and then send another request with the message ID.
I want to download the attachments so in the response object im searching for the Payload.Parts field of the response object
In Label_1 response - Payload.Parts[0] contains the filename field and Payload.Parts[0].Body contains the attachmentID
In Label_2 response - Payload.Parts[1].Parts[0] contains the filename and same for .Body contains the attachmentID.
my question is: why this is happening?
why in one response i get the wanted fields in the first Payload.Parts and in the second i have to go deeper in the object's fields?
I've also noticed that in Label_1 response I receive an HTTP header which I dont get on the second one that I think may be related: DKIM-Signature
any thoughts?
Thanks.
The response you get is just the RFC822-message parsed to JSON. The message might be multipart/mixed, multipart/related, text/html or something similar. It is best to write your code so you check all parts in the payload:
var response = {
"payload": {
"parts": [
{
"mimeType": "multipart/alternative",
"filename": "",
"headers": [
{
"name": "Content-Type",
"value": "multipart/alternative; boundary=001a1142e23c551e8e05200b4be0"
}
],
"body": {
"size": 0
},
"parts": [
{
"partId": "0.0",
"mimeType": "text/plain",
"filename": "",
"headers": [
{
"name": "Content-Type",
"value": "text/plain; charset=UTF-8"
}
],
"body": {
"size": 9,
"data": "V293IG1hbg0K"
}
},
{
"partId": "0.1",
"mimeType": "text/html",
"filename": "",
"headers": [
{
"name": "Content-Type",
"value": "text/html; charset=UTF-8"
}
],
"body": {
"size": 30,
"data": "PGRpdiBkaXI9Imx0ciI-V293IG1hbjwvZGl2Pg0K"
}
}
]
},
{
"partId": "1",
"mimeType": "image/jpeg",
"filename": "feelthebern.jpg",
"headers": [
{
"name": "Content-Type",
"value": "image/jpeg; name=\"feelthebern.jpg\""
},
{
"name": "Content-Disposition",
"value": "attachment; filename=\"feelthebern.jpg\""
},
{
"name": "Content-Transfer-Encoding",
"value": "base64"
},
{
"name": "X-Attachment-Id",
"value": "f_ieq3ev0i0"
}
],
"body": {
"attachmentId": "ANGjdJ_2xG3WOiLh6MbUdYy4vo2VhV2kOso5AyuJW3333rbmk8BIE1GJHIOXkNIVGiphP3fGe7iuIl_MGzXBGNGvNslwlz8hOkvJZg2DaasVZsdVFT_5JGvJOLefgaSL4hqKJgtzOZG9K1XSMrRQAtz2V0NX7puPdXDU4gvalSuMRGwBhr_oDSfx2xljHEbGG6I4VLeLZfrzGGKW7BF-GO_FUxzJR8SizRYqIhgZNA6PfRGyOhf1s7bAPNW3M9KqWRgaK07WTOYl7DzW4hpNBPA4jrl7tgsssExHpfviFL7yL52lxsmbsiLe81Z5UoM",
"size": 100446
}
}
]
}
};
// In e.g. a plain text message, the payload is the only part.
var parts = [response.payload];
var attachmentIds = [];
while (parts.length) {
var part = parts.shift();
if (part.parts) {
parts = parts.concat(part.parts);
}
if(part.body && part.body.attachmentId) {
attachmentIds.push(part.body.attachmentId);
}
}
console.log(attachmentIds);

Resources