jalendport / craft-fetch

Utilise the Guzzle HTTP client from within your Craft templates.
MIT License
24 stars 13 forks source link

Multipart form with form data is not working #11

Open parthi-me opened 2 years ago

parthi-me commented 2 years ago

I have tried to post my form values using the multipart option(https://docs.guzzlephp.org/en/stable/request-options.html#multipart), like the below in my twig template file,

{% set client = {
        base_uri : 'baseURL',
        timeout : 10
    } %}

    {% set destination = 'URLremianing part' %}

    {% set options = {
        headers: {
            'Content-Type': 'application/json',
            'Accept': 'application/json',
            'Authorization': 'Bearer xxxx',
        },
        multipart:[ {
            'name': 'title',
            'contents':  'mr'
        }]
    } %}
getting the error "title" field is required.

Whereas, if I send using the JSON option(https://docs.guzzlephp.org/en/stable/request-options.html#json) it works perfectly,
instead of multipart in the above code, I replaced with, 
   json: {
            'title': 'mr',
            'first_name':  '1'
    }

Can someone please confirm multipart will work with form data fields?

Note : craft cms version(3.7.34)