0

I'm building a NextJS webapp in which a user is supposed to complete his profile by uploading his national ID. I'm saving the uploaded file using Laravel. Everything works fine till the saving part. But when I'm trying to send the saved to file to an external API, the API throws me an error asking me to Send a valid image. The external API accepts, JPG, JPEG and PDF. Here's my code:

$pan = Storage::get(auth()->user()->pan_photo);
$data = ['pancard' => $pan,];
$response = Http::asForm()
            ->withHeaders([
                'some custom headers'
            ])->put('https://staging.eko.in:25004/ekoapi/v1/user/service/activate', $data);
Log::channel('response')->info($response);

Am I doing something wrong here?

1

1 Answer 1

0

You have to use POST here, A PUT/PATCH will not work as this is a limitation of the PHP, So instead of using put function you need to change it to post

<?php 
Http::asForm()->post('Your url here', $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.