Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
kelvins19 opened this issue Dec 23, 2020 · 2 comments
Open

Comments

@kelvins19
Copy link

    $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!

@elimentz
Copy link
Contributor

Can you ask the API provider to give you a native cURL example of what the syntax should look like? If you have that, it should be pretty easy to transfer that into the package syntax

@kelvins19
Copy link
Author

Can you ask the API provider to give you a native cURL example of what the syntax should look like? If you have that, it should be pretty easy to transfer that into the package syntax

I have asked them, unfortunately they don't have any examples yet.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants