1

I'm trying to submit JSON data directly to a webform through some restful resource. My thought was to create a webform, enable webform_service, and then post directly to the endpoint. This lead me to try something like this:

curl -vv -X POST -H "Content-Type: application/json" -d '{"title":"Contact Us", "submitted[contact_fullname]": "my name", "submitted[contact_email]": "[email protected]", "submitted[contact_message]": "test message"}' http://localhost/api/contact_us.json

But this does not work. In fact without the "title" value I get "title field is required", which seems to be trying to create a new webform, and in fact if I provide a title, a new webform is, in fact, created. But this is not what I'm looking to do - I'm trying to submit a new entry into the existing webform.

I thought that perhaps there's a different resource that I should be submitting form data to:

curl -vv -X POST -d 'submitted[contact_fullname]=sundartest&submitted[contact_email][email protected]&submitted[contact_message]=test_message' http://ike.localhost/api/contact_emc.submission

But obviously this is wrong and I'm just guessing!

Any pointers on how I can accomplish this?

1

2 Answers 2

2

https://stackoverflow.com/users/763010/tyler-frankenstein created a grate article that can be found here

you might also find https://stackoverflow.com/questions/10428014/steps-to-make-a-mobile-application-using-drupal-as-a-back-end-or-service/13662041#13662041 useful it has links to articles that describe services in full.

I'd also advise a couple plugins Firefox: poster Chrome: postman

http://drupal.org/node/1795770 might be more applicable it's how to login, post a comment, and loggout from curl hope it helps.

2
0

Per the comment previously, I'm just closing this with the solution that worked for me:

How to submit webform programmatically with Ajax?. It must be done with as an AJAX POST with JSON data, rather than form data.

Your Answer

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

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