Create Quote with api Rest

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mkhalifa
    Member
    • Jan 2019
    • 48

    Create Quote with api Rest

    Hello,


    I wanted to make a simple test of creation of a quote via the API and I send the name of the quote for the moment. I work in php and I use the API client https://github.com/espocrm/documenta...-client-php.md below the code I made

    PHP Code:
    include 'espocrm.php' ;
    $client = new EspoApiClient('mycloudcrmurl');
    $client->setApiKey('myapikey');
    $response = $client->request('POST', 'Quote', [
        'name'=> 'testt'
    ]);
    
    var_dump( $response); 
    
    Response :

    PHP Code:
    PHP Fatal error:espocrm.php:138
    Stack trace:
    #0 testEspoAPI.php(11): EspoApiClient->request('POST', 'Quote', Array)
    #1 {main}
      thrown in espocrm.php on line 138 
    
    I did the same test to create a lead and it works without problems and also to create an account. Something escapes me for creating quotes?
    Note: I'm working on the demo cloud version.
  • yuri
    Member
    • Mar 2014
    • 8467

    #2
    Does the user have a create access for quote entity?
    If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

    Comment

    • yuri
      Member
      • Mar 2014
      • 8467

      #3
      You can try catch request and print $client->getResponseHttpCode();
      If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

      Comment

      • mkhalifa
        Member
        • Jan 2019
        • 48

        #4
        Hi Yuri,
        Thanks for your replay
        with try catch echo $e->getMessage() ; return :
        PHP Code:
        EspoClient: Unknown Error 
        
        and if i try print $client->getResponseHttpCode(); in catch i have :

        PHP Code:
        EspoClient: Unknown ErrorPHP Warning:  curl_getinfo(): 5 is not a valid cURL handle resource in espocrm.php on line 179 
        
        you can see in the attachment capture the rights attributed to the user, What I can not understand is that I gave all possible rights to the user but I always disabled on the Quote line.


        I can give you to my demo environment if you want to check or test yourself.

        Thanks you

        Comment

        • yuri
          Member
          • Mar 2014
          • 8467

          #5
          Make sure you have enabled create access in at least one of roles assigned to your API User.

          Clear cache just in case.
          If you find EspoCRM good, we would greatly appreciate if you could give the project a star on GitHub. We believe our work truly deserves more recognition. Thanks.

          Comment

          • mkhalifa
            Member
            • Jan 2019
            • 48

            #6

            Thank you very much Yuri that was the problem

            Comment

            Working...