API Multiple Calls

Hi everyone,

I’m using the FrappeClient, trying to creat multiple Material Request. I need to search BOM, Project data, Customer data to complete Material Request insert data.

If I run each one, it runs smoothly, like 1 seg
If I run 2 calls, the call takes 5 seconds.
At the 3rd call, the system throw an “Auth Fail” exception.

I change the order and the result it’s the same. 3rd call, it fails.

Is there any request limit on the API? If so, where change that? I need to do those calls n-times. Depends on the user request.

Could you share your code snippet?

Hi,

I’m using this class

https://github.com/tmimori/FrappeClient-PHP/blob/master/FrappeClient.php

Along with:

 public function recuperarOrden($url) {
        $variable = 0;
        $operar = file_get_contents ( $url );
    
        if (strlen ( $operar ) > 0) {
            $variable = json_decode ( $operar, true );
        }
        
        return $variable;
    }

Where $operar result is:

`    public function consultarOrdenTrabajo($datosConexion = '', $parametros) {
    
        $this->configurarERPNext ( $datosConexion );
        $data = array (
                "id_orden_trabajo" =>$parametros 
        );
        
        $fields = array (
                "id_orden_trabajo",
                "project_name",
                "descripcion_orden" 
        );
        
        $result = $this->clientFrappe->search( "Orden Trabajo", $data, $fields );

        if (! empty ( $result->body->data )) {
            echo json_encode ( $result->body->data );
        }
        
        return false;
    }`

All the calls have the same structure,

Sorry to jump in on this subject but I am experiencing the same issue and I can’t seem to find a fix to it.

@violetasdev can you please detail the fix you got ?

Thank you in advance.

Hi @MaysaaSafadi ,

In case you still are interested in the answer.

The solution was to built a REST class service to send and receive the server request.

The credential data is on a separate DB and it’s recovered just once. One cookie maintein the session alive so we can manage to make multiple calls (send a request, update the documents and receive the result we need to save to our separate db not in ERPNext DB)

As I share, I use a modified version of the FrappClient class above along with request class manager and request class processing.

In our application, we manage the calls and the results, nothing more.

The key is keeping alive your cookie and manage the API server response in order to avoid errors.

We were able to make around 300 sales invoice including Client creation in case it needed and saving the results in our DB to make other service stuuf we requiered.

If there is any more questions, feel free to ask.