0

I have exposed a GET in an API which returns an application/csv back to the caller. NB: the resulting application/csv is just a string. The caller wants the result to include a BOM.

This is how I set the contents of the returned application/csv with MEL:

#[flowVars.csvFile]

I am trying to add the BOM with a simple concatenation, but it doesnt work.

How should I add the BOM in the beginning of a String?

If it cannot be done with MEL, is there a way with dataweave or java/groovy?

Stanislav Ivanov
  • 425
  • 2
  • 7
  • 19
  • Hi @Aaron, the problem is that the file in the article you are pointing to is directly written to the file system while I return the resulting client back over HTTP call – Stanislav Ivanov Sep 14 '18 at 11:08
  • Wouldn't the most upvoted answer still work for you? You must have an OutputStream somewhere on which you could `write('\ufeff')`, haven't you? – Aaron Sep 14 '18 at 12:10
  • @Aaron you are right, this works when I test groovy only. However, it is Mule that changes the String and it strips the BOM when it gets returned to the customer. – Stanislav Ivanov Sep 14 '18 at 13:09
  • Ah, I can't help you there, I don't know the first thing about Mule. Still, I'd expect a settings to disable such feature. – Aaron Sep 14 '18 at 13:10

1 Answers1

0

It turns out Postman do not show the BOM. Otherwise the linked solution works perfectly.

Stanislav Ivanov
  • 425
  • 2
  • 7
  • 19