POST Forbidden for QuoteItem via API REST

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • oscarbm92
    Junior Member
    • May 2017
    • 18

    POST Forbidden for QuoteItem via API REST

    Hi!

    Im trying to create QuoteItems records via API REST

    (/api/v1/QuoteItem)
    Response: 403 Forbidden

    Log:
    Espo.ERROR: (403) Quote Item can be created only within Quote record.; POST .../api/v1/QuoteItem; line: 25, file: .../application/Espo/Modules/Advanced/Controllers/QuoteItem.php [] []

    I want to remove that restriction in order to create records from a connected app via api rest.

    How can i achieve this?

    Thank you!

    Last edited by oscarbm92; 03-14-2020, 03:19 AM.
  • yuri
    Member
    • Mar 2014
    • 8483

    #2
    Hi,

    Just use the search in file contents by the phrase "Quote Item can be created only" and you will find the place where you will need to remove the restriction.
    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

    • oscarbm92
      Junior Member
      • May 2017
      • 18

      #3
      Thanks, yes, i think its only in the file QuoteItem.php in /application/Espo/Modules/Advanced/Controllers

      tried to comment the line:

      PHP Code:
      public function actionCreate($params, $data, $request)
      {
           //throw new Forbidden('Quote Item can be created only within Quote record.');
      } 
      
      Then i tried to do a POST call with response 200 OK but nothing happens, im missing something? Thank you!

      EDIT:
      Nevermind, commenting all the method worked, now I'm having a error:

      Espo.ERROR: (400) Not valid data. Field: 'unitPrice', type: required.; POST /crm/api/v1/QuoteItem;

      When my payload actually have it

      Code:
      {
          "name": "Agua",
          "quantity": 1,
          "listPrice": 15,
          "unitPrice": 15,
          "discount": 0,
          "amount": 15,
          "instrucciones": null,
          "listPriceCurrency": "MXN",
          "unitPriceCurrency": "MXN",
          "amountCurrency": "MXN",
          "quoteId": "5e6da3c2426f82cd2",
          "quoteName": "TWH000069",
          "productId": "5e4f1bcc994da53c3",
          "productName": "Agua",
          "listPriceConverted": 15,
          "unitPriceConverted": 15,
          "amountConverted": 15,
          "comandaId": "5e6da3c24510f8514",
          "comandaName": "CMD000131"
      }
      Last edited by oscarbm92; 03-15-2020, 04:20 AM.

      Comment

      • oscarbm92
        Junior Member
        • May 2017
        • 18

        #4
        Ok, i removed the check "required" of all fields in QuoteItem for testing and figured out that for some reason somehow it's not getting all the payload data, never happend to me before, it is only with this QuoteItem Entity the rest of my api calls are working fine, any ideas what is going on or how i can fix this? Thank you!

        Comment

        Working...