Adding rich text on web-form using REST API | Community
Skip to main content
Amit_Jain
Community Manager
Mar 12, 2019 12:02 PM UTC
Question

Adding rich text on web-form using REST API

Hi There,

I have to add a rich text on all the form. I was trying to the same using the REST API but getting following error in response:

{"success":false,"errors":[{"message":"label cannot be null","code":"701"}],"requestId":"11658#16971c2c33e","warnings":[]}

Following is my payload and end point URL:

var url = 'https://'+munckin_Id+'.mktorest.com/rest/asset/v1/form/' + formId + '/richText.json?access_token=' + access_token

var options = {

'method': 'post',

'contentType': 'x-www-form-urlencoded',

'addRichTextRequest': {

'text':'Hey this is from API',

}

};

according to the doc we don't need to add label any where not sure why I'm getting this error. Following the developer doc URL

http://developers.marketo.com/rest-api/endpoint-reference/asset-endpoint-reference/#!/Form_Fields/addRichTextFieldUsingP…

Thank you for your help in advance.

Regards,

Amit

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

7 replies

Amit_Jain
Amit_JainAuthor
Community Manager
Mar 15, 2019 5:30 AM UTC

Thank you Sanford. It's helpful!

Translate
Level 1
Jun 10, 2020 10:32 AM UTC

Hi Amit,

 

I'm having the same issue as you, did you manage to figure out what was wrong?

PostURL = host + "/rest/asset/v1/form/" + id + "/richText.json?" + qs.ToString(); HttpWebRequest request = (HttpWebRequest)WebRequest.Create(PostURL); request.Method = "POST"; string boundary = "--mktoBoundary" + DateTime.Now.Ticks.ToString("x"); request.ContentType = "multipart/form-data; boundary=" + boundary; var wr = new StreamWriter(request.GetRequestStream()); wr.Write("--" + boundary + "\\r\\n"); wr.Write("Content-Disposition: form-data; name=\"text\"\\r\\n"); wr.Write("Content-type: text/html; charset=\"utf-8\"\\r\\n"); wr.Write("<div>content</div>" + "\\r\\n"); wr.Write("--" + boundary + "--"); wr.Flush(); HttpWebResponse response = (HttpWebResponse)request.GetResponse(); Stream resStream = response.GetResponseStream(); StreamReader reader = new StreamReader(resStream);

 I get error 701 "label cannot be null"

Translate
SanfordWhiteman
Level 10
Mar 12, 2019 6:11 PM UTC

"addRichTextRequest" is just the JSON schema type. It has no inherent meaning in your app unless you have some kind of schema binding, and it doesn't appear in the the JSON payload. Only the text property appears.

{

"text" : "Text Goes Here"

}

Also, please don't supply anything language-specific because we have no idea what the rest of your code looks like, what HTTP library you're using, etc. The only thing that ever matters with a REST API is the final JSON that goes on the wire.

Translate
Amit_Jain
Amit_JainAuthor
Community Manager
Mar 13, 2019 5:37 AM UTC

Thank you for your reply @Sanford Whiteman​!

I tried following but still getting the same error:

var options = {

'method': 'post',

'text':'Hey this is from API'

};

Is this what you mean or I'm still doing something wrong?

I do not have any standard setup to develop the app. I'm actually using Google App script here.

Thank again for your reply!

Regards,
Amit

Translate
SanfordWhiteman
Level 10
Mar 13, 2019 5:50 AM UTC

What exactly is going on the wire? You need to show the HTTP request exactly as-is.

Translate