0

I am trying to pass text like

"Video Transmission & internal Recording

No Filters

1x 11 Handheld Monitor 1x 19 Monitor"

--> so 5 and more likes with several empty line inbetween as a single text from make(integromat).com to Lexoffice via HTTP request as ... "description": "ItemDescription" ... with "ItemDescription" being the multi-line long text and I get an error from HTTP Module saying "Error: 400 Bad Request, The request body could not be parsed due to malformed json syntax."

But I need the multi-line item to appear in Lexoffice on the invoice.

Is there a workaround for it?

I expect the long multiline text to appear on the invoice where I try to paste it with the http module

My Lexoffice-API HTTP code for URL https://api.lexware.io/v1/quotations, POST:

{
  "voucherDate": "{{formatDate(now; "YYYY-MM-DDTHH:mm:ss.SSSZ")}}",
  "expirationDate": "{{formatDate(addDays(now; 14); "YYYY-MM-DDTHH:mm:ss.SSSZ")}}",

"address": 
{
    "contactId": "{{48.data.content[].id}}"
  },

"lineItems": {{108.LineItems}},

  "totalPrice": { "currency": "EUR" },
  "taxConditions": { "taxType": "net" },
  "shippingConditions": {
    "shippingType": "service",
    "shippingDate": "{{formatDate(now; "YYYY-MM-DDTHH:mm:ss.SSSZ")}}"
  }
}

LineItems are being set as variable {"type":"material", "id":"{{69.data.id}}", "name":"{{69.data.title}}", "description":"{{69.data.description}}"}. After that I do {{map(66.array; "LineItems")}} and after that "108.LineItems" = [{{join(104.LineItems_v0; ", ")}}]. Error is due to description length as if I delete/shorten it (to single line), all works.

1 Answer 1

0

The correct way to escape newlines in JSON is to replace them with the string \n

Example below is using \n\n for double lines (this is like pressing Enter key two times):

"Video Transmission & internal Recording\n\nNo Filters\n\n1x 11 Handheld Monitor 1x 19 Monitor"
Sign up to request clarification or add additional context in comments.

2 Comments

OMG that's great, I was looking for a solution for a looong time!! that helps a lot!! One question through - if my Description is a variable, how can i look in make for the empty lines in it and replace them with \n\n?
Sorry I don't use Make so not sure how variables are used there (is it Javascript??). If you've now got a solution about that, then post it as a new Answer to help others. If not solved, then I'm not sure what to suggest because a variable exists in the code editor and there is no real "new line" concept inside code editors. If the variable loads text from outside (lexample: a text file) then it can be done (eg: a text file has new lines added automatically)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.