Skip to content

How to Curl (ContentType: multipart/form-data) to API without file data? #125

@kelvins19

Description

@kelvins19
    $jsonField = [
        'user_id'       => 'userid',
        'document_id'   => 'documentid', 
    ];
    $jsonFile = ['JSONFile' => $jsonField];

    $output = Curl::to('$url')
        ->withHeader('Authorization:Bearer ' . $token)
        ->withContentType('multipart/form-data')
        ->withData([
            'jsonfield'     => json_encode($jsonFile)
        ])->asJsonResponse()
        ->post();

Hi, I have been trying to send request to API server, it requires multipart field as its ContentType. But when i checked with the API provider, they said that the json data is not been received in their server, only the header. I have used this method for other API request that they have and it works well. The only difference is that the other have file upload and this one doesn't.
Does anyone have experienced this?
Any solution / help will be appreciated. Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions