Outlook 365 file attachment option auto-applies CSV column headers - mule

I need to develop an integration using Mule which will create a *.csv file without headers, and email the file content as email attachment using Outlook 365.
Using DataWeave 2.0, I defined output application/csv header = false to create required CSV content without headers. Output of the DataWeave script is correct, which I checked in application logs and also by writing to local file system.
In the next step, I am passing this output payload to Outlook 365 using below code (MuleSoft Outlook 365 connector internally uses Outlook mail REST API - https://learn.microsoft.com/en-us/graph/api/resources/mail-api-overview?view=graph-rest-1.0):
%dw 2.0
import * from dw::core::Binaries
output application/json
---
{
"message": {
"subject": "Summary-" ++ now() as String {
"format": "yyyyMMdd"
},
"body": {
"contentType": "Text",
"content": "Please find attached summary"
},
"toRecipients": [{
"emailAddress": {
"address": p('outlook.toRecipients')
}
}],
"attachments": [{
"#odata.type": "#microsoft.graph.fileAttachment",
"name": "service-data.csv",
"contentType": "application/csv",
"contentBytes": toBase64(write(payload, "application/csv"))
}]
},
"saveToSentItems": "true"
}
Receiver of this email finds column headers created in the attached file, example:
column_0,column_1,column_2,column_3,column_4,column_5,column_6,column_7,column_8,column_9,column_10,column_11,column_12,column_13,column_14,column_15,column_16,column_17,column_18
,SDEN1001107GR,Dense 7.3N 100mm,Days,0,,Blank,,,,,,,,,,,,
I debugged this, and looks like Outlook 365 connector automatically adds column header 'column_X' if not defined. But, the requirement is not to include headers in the file attachment.
Could anybody please help how to ignore the column headers in email attachment?
Sample request payload:
[
{
"Code": "SDEN1001107GR",
"UnitUsagesUsage": "Days",
"Group": "Blank",
"Category": "A",
"Description": "Dense 100mm",
"Rate": "0"
}
]

The issue seems to be that DataWeave -not the connector- is receiving the header=false property as a reader property rather than a writer property. For example in the read() function or in the outputMimeType attribute of a source or operation. Reader properties apply to the input of the script.
You need to use as a writer property instead for the property to be applied to the output.
In the write() function you add writer properties as an additional parameter:
write(payload, "application/csv", {header: false})

Related

Shopware 6 Admin Api - Updating existing record through patch method. Not working

shopware 6 admin api patch - why it's failing? I get error "Only single write operations are supported"
Following is api for rule-condition entity in the database, I update it with Id.
For same api get method is working!
url: api/rule-condition/dbb0d904c7c14860a9a94cf26b94eca6
method: patch
json body
[
{
"op": "replace",
"path": "/data/attributes/value/email",
"value": "test#gmail.com"
}
]
response:
{
"errors": [
{
"code": "0",
"status": "400",
"title": "Bad Request",
"detail": "Only single write operations are supported. Please send the entities one by one or use the /sync api endpoint.",
.......
I also tried changing json body to following
{
"data": {
"attributes": {
"value": {
"email": "test#gmail.com"
}
}
} }
Still it's not updating. Can somebody check and let me know what am i missing?
Documentation I followed:
https://shopware.stoplight.io/docs/admin-api/ZG9jOjEyMzA4NTQ5-writing-entities
This website has all apis and example methods. https://swagger.docs.fos.gg/,
rule-condition entity can also be found there.
Btw : I used postman for testing api
You're passing an array of objects in the request body, suggesting you want to update multiple records, but the endpoint only supports updating a single record. The correct payload in your case should look like this:
{
"value": {
"operator": "=",
"email": "test#gmail.com"
}
}
Notice that value is a json field and not only includes a single value. The exact content and the names of the properties of value depend on the type of condition used and usually it also includes the operator used in the condition.

How to keep both button text and payload in whatsapp quick reply message template

Whatsapp quick reply request template has option for payload only. In what option we can configure the button text. After lots of searching on internet I did not find proper solution.
Here is the json of button which need to be send in request but it only has the payload option
{
"type": "button",
"sub_type" : "quick_reply",
"index": "0",
"parameters": [
{
"type": "payload",
# Business Developer-defined payload
"payload":"aGlzIHRoaXMgaXMgY29vZHNhc2phZHdpcXdlMGZoIGFTIEZISUQgV1FEV0RT"
}
]
},
Reference link: https://developers.facebook.com/docs/whatsapp/api/messages/message-templates/interactive-message-templates#request
You need to configure that in the Facebook Business Manager UI or in the Graph API post request when you create the template. When you're sending the message, you can't dynamically configure the text.

Alfresco : searching filed which for specific Metadata field

In Alfresco we have the JSON representation of Metadata fields of a file. The following one is for an Image file:
{
"mimeType": "image/png",
"downloadUrl": "",
"content": {
"type": null,
"version": "",
"attributes": {
"resolutionUnit": "Inch",
"software": "Adobe Photoshop"
},
"newContentIconDuration": null,
"creationDate": "2016-08-03T14:58:32.656-04:00"
}
}
I am working on requirement to search all images files, which contains Metadata field "software": "Adobe Photoshop" (as we can see in above json structure).
By using the following code I can search all files in alfresco, which have 'mimeType' 'image/jpeg', but not sure how can I search for metadata "software": "Adobe Photoshop" ?
var docs = search.luceneSearch("#cm\\:content.mimetype:\"image/png\"");
Any suggestion please ?
I am able to get it now by using this statement :
var docs = search.luceneSearch("#exif\\:software:\"Adobe Photoshop\"");
Steps to get this field name is ==> go to Alfresco Admin Consile -> Node Browser
and put this value in PATH field with 'Nodref" selected : "workspace://SpacesStore/REFERENCEIDOFTHEFILE" . There we can see the Name of fields which is being used. Like in this case it is exif:software.

POSTMAN COLLECTION RUNNER: passing the all body post request as a variable?

I have a POST request template - instead putting all the JSON body i put a variable: {{bodyRequest}}
now i have a json file that looks like this(Below code bloc) that i upload in my collection runner as data json: my intention is to fetch {{bodyResponse}} from the iteration and make the post call in the api.
[
{ "{{bodyRequest}}":
{
"order": {
"order_date":"{{$timestamp}}",
"order_number":"{{$guid}}",
"reference":"Scenario1",
"destination":
{
"name":"test",
"phone":"00000",
"email":"test#test.com",
"company":"My Company",
"building":"My Building",
"street":"my street",
"suburb":"my sububr",
"post_code":"my postcode",
},
}
}
}
]
Then i click run
Open Collection Runner
Add Data file in Format JSON (above in code)
declare it as Json
run collection
Error Log
Request Body:"{{bodyRequest}} "
instead the all payload
thank you so much
Franco

How to post event with metadata to stream through HTTP API

I'm using EventStore and want to post a message (event) to it. I use the HTTP API for testing purposes. I've managed to post the event itself, with an event type specified, but I can't figure out how to specify metadata for my event. (and I must provide this metadata because my consuming application on the other side expects it).
This is what my HTTP request looks like:
Content-Type: application/json
ES-EventType: My.own.event.type
POST http://10.0.75.2:2113/web/index.html#/streams/foobar
{
"props": "andvalues"
}
Do I specify metadata in the body in through headers? I can't find much docs about this, only the official that doesn't mention it.
The documentation mentions the full schema for an event being written. It looks like this:
[
{
"eventId" : "string",
"eventType" : "string",
"data" : "object",
"metadata" : "object"
}
]
For example:
[
{
"eventId": "fbf4a1a1-b4a3-4dfe-a01f-ec52c34e16e4",
"eventType": "event-type",
"data": { "a": "1" },
"metadata": { "b": "2" }
}
]
Note that it's an array, and that you must pass content-type as application/vnd.eventstore.events+json
Check this page, scroll to Event Store Events Media Type.