From Chrome Postman call a POST request over json.

URL: contact_message?_format=json
Basic Auth...
Content-type: application/json

Body:

{
    "contact_form":[{"target_id":"my_contact_form_machinename"}],
    "name":[{"value":"my_login_name"}],
    "mail":[{"value":"my_email"}],
    "subject":[{"value":"REST contact form"}],
    "message":[{"value":"REST message body"}]
}

Message:
{"message":"No route found for \u0022POST \/contact_message\u0022"}

Maybe there is a solution?

Comments

ardonos created an issue. See original summary.

ardonos’s picture

Issue summary: View changes
inetkid’s picture

This is Chrome browser-side javascript + jQuery that worked. Empty response is the correct result.

jQuery.ajaxSetup({ headers: { 'X-CSRF-Token': csrftoken } }); // get token from /rest/session/token
var d = {
  'contact_form':[{'target_id':'feedback'}],
  'name':[{ 'value': document.getElementById('edit-name').value }],
  'mail':[{ 'value': document.getElementById('edit-mail').value }],
  'subject':[{ 'value': document.getElementById('edit-subject-0-value').value }],
  'message':[{ 'value': document.getElementById('edit-message-0-value').value }]
};
jQuery.ajax({ type: 'POST', 
  url: '/contact_message?_format=json', 
  data: JSON.stringify(d), 
  contentType: "application/json", 
  dataType: 'json', 
  success: function() { alert('Message sent'); } 
});
svendecabooter’s picture

Status: Active » Closed (outdated)