Create Quote with quote items via API

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • LuckyLouie
    Senior Member
    • Nov 2017
    • 172

    Create Quote with quote items via API

    Hello,
    is possible create quote with quote items via API Create?
    To create Quote I use:
    PHP Code:
    ?php
    
    require_once('EspoApiClient.php');
    
    $url = 'https://page.com';
    $apiKey = '1830d555dd1*************435284c9c';
    
    $client = new EspoApiClient($url);
    $client->setApiKey($apiKey);
    
    // example creating a new lead
    try {
    $response = $client->request('POST', 'Quote', [
    'name' => 'Test Z API',
    ]);
    } catch (\Exception $e) {
    $errorCode = $e->getCode();
    } 
    
    How to add items?

    Thanks for any help
    Last edited by LuckyLouie; 05-31-2021, 12:53 PM.
  • emillod
    Active Community Member
    • Apr 2017
    • 1445

    #2
    As far as i remember, you should create new quote just with itemList parameter. If you want to add them to already existing quote, try to use PUT request to do so. You could try also to send request directly to the QuoteItem entity, but i think it shouldn't be a problem to create them through Quote entity.

    Go to Postman/Insomnia, send GET request for already existing Quote with ItemList, copy response from EspoCRM, delete/adjust parameters like id's, dates, etc. and then send this response as a body in POST request. You'll see thanks to that how it works.

    Comment

    Working...