0

I am trying to submit enquiry form using api.
I am able to post data through api by using the endpoint

  • Endpoint: url/contact_message?_format=json
  • Body:

{
    "contact_form":[{"target_id":"enquiry_form"}],
    "field_phone":[{"value":"123456789"}],
    "message":[{"value":"VALUE"}],
    "subject":[{"value":"VALUE"}]

}

  • Request type: POST

I am able to post the fields.
But how can i upload the file also using api if i know the base64 value of a file. Do I have to make separate custom module/controller?

  • You shouldn't know the file base64, enable rest "File upload" resource, and from app post the file to 'let uri = /file/upload/${entity_type_id}/${bundle}/${field_name}?_format=json;', fiels are in 'let files = (<HTMLInputElement>event.target).files;', so first attached is 'files[0]' – svetlio Jan 10 at 14:43

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Browse other questions tagged or ask your own question.