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

OCR endpoint not working #75

Open
drazenmatic opened this issue Nov 6, 2023 · 3 comments
Open

OCR endpoint not working #75

drazenmatic opened this issue Nov 6, 2023 · 3 comments

Comments

@drazenmatic
Copy link

drazenmatic commented Nov 6, 2023

Endpoint for ocr is not working.

It is throwing a validation error message about provider not being set, while within guzzle it is clearly being set and passed.

Your live preview cannot test when header is set to 'Content-Type' => 'multipart/form-data;'
https://docs.edenai.co/reference/ocr_ocr_create

$client = new \GuzzleHttp\Client();

$response = $client->post('https://api.edenai.run/v2/ocr/ocr', [
    'multipart' => [
        [
            'name' => 'providers',
            'contents' => 'api4ai'
        ]
    ],
    'headers' => [
        'Authorization' => 'Bearer ' . $this->token,
        'Content-Type' => 'multipart/form-data;'
    ]
])

Response

 Client error: `POST https://api.edenai.run/v2/ocr/ocr` resulted in a `400 Bad Request` response:
    {"error":{"type":"Invalid request","message":{"providers":["Please enter the name of the provider(s)"]}}}
@gpuligundla
Copy link

Can I work on this issue?

@ghoshsanjoy78
Copy link

Is this issue fixed ? Still happening for me

@juandavidcruzgomez
Copy link
Contributor

Hi, it seems to me that the issue is with the formatting pf the providers. It should be a list:
In your PHP code you should have something like:

$client = new \GuzzleHttp\Client();

$response = $client->post('https://api.edenai.run/v2/ocr/ocr', [
    'multipart' => [
        [
            'name' => 'providers',
            'contents' => '["api4ai"]' // <-- This must be a list of strings
        ],
        [
          'name' => 'file',
          'contents' => Utils::tryFopen('/path/to/your/document.pdf', 'r'),
          'filename' => 'your_document.pdf',
          'headers'  => [
            'Content-Type' => '<Content-type header>'
          ]
        ]
    ],
    'headers' => [
        'Authorization' => 'Bearer ' . $this->token,
        'Content-Type' => 'multipart/form-data;'
    ]
])

Note that the file part is just an example, and you need to adapt it to your problem.
Hope it helps.

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

4 participants