I am writing an application (non-Drupal) that is POSTing to a 3rd party public form written in Drupal. The problem I am running into is that the 3rd party form never processes the request, it only returns the original form. Is there a trick to posting to Drupal forms? The URL that I am attempting to post to is:


The response should have the following fragment:

<div role="alert">
  <h2 class="visually-hidden">Error message</h2>
  No match found for AMA 123 and last name smith. Please verify.

But it does not.


There is no special trick to posting to Drupal Forms. But, the way that form is set up, at least for validation errors, is ajax-based. Which means that you need to post to this URL instead:


with the following parameters

_drupal_ajax    1
_triggering_element_name    op
_triggering_element_value   Submit
ajax_page_state[libraries]  classy/base,classy/messages,core/drupal.ajax,core/html5shiv,core/jquery.form,core/normalize,extlink/drupal.extlink,google_analytics/google_analytics,nt_ama/nt_ama,omega/omega,responsive_menu/responsive_menu.javascript,responsive_menu/responsive_menu.styling,system/base,tb_megamenu/theme.tb_megamenu
ajax_page_state[theme]  nt_ama
ama_number  123
form_build_id   form-pqXufm7ga3qhXz5_dpM6_AiGcgcExovHqBG6kkqcIIE
form_id membership_verify_form
last_name   smith

That should give you a json response, similar to this:

    "command": "update_build_id",
    "old": "form-pqXufm7ga3qhXz5_dpM6_AiGcgcExovHqBG6kkqcIIE",
    "new": "form-_2pgVtOL0WW10yWGP8iS1o95GyJ5pMxo5M1Mk3Jy90c"
}, {
    "command": "insert",
    "method": "html",
    "selector": "#messages-wrapper",
    "data": "    \u003Cdiv role=\u0022contentinfo\u0022 aria-label=\u0022Error message\u0022 class=\u0022messages messages--error\u0022\u003E\n          \u003Cdiv role=\u0022alert\u0022\u003E\n                  \u003Ch2 class=\u0022visually-hidden\u0022\u003EError message\u003C\/h2\u003E\n                    No match found for AMA 123 and last name smith. Please verify.\n                \u003C\/div\u003E\n      \u003C\/div\u003E\n    ",
    "settings": null

which contains the message you mention.

Good luck!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.