Announcement

Collapse
No announcement yet.

Issues when updating products via API

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Issues when updating products via API

    Hi,

    So I've created a parser in C# that gets prices, stock on hand and other info from one of our distributors.

    The products are created manually in EspoCRM then mapped via ID in my parser.

    The problem I'm facing is that if I don't set Cost price field to 0 I get an validation error.

    Endpoint


    Payload
    {
    "url": "https://domain.com/p/powerwalker-vi-2200-lcd-ups-1200watt-2200va-988850910",
    "costPrice": 150.35,
    "weight": 12.16,
    "status": "Available",
    "cStockOnHand": 2,
    "cEanCode": "4260074976502"
    }

    Error
    {
    "messageTranslation": {
    "label": "validationFailure",
    "scope": null,
    "data": {
    "field": "costPrice",
    "type": "validCurrency"
    }
    }
    }

    Now I know how to work around it by setting the initial price to zero. Just wondering if it's the intended behaviour.

  • #2
    Not sure. "validCurrency" validation is failed when a passed currency is not one of the currencies allowed in the system.

    Comment


    • #3
      novastream I had the same "issue", ended up skipping validation for currency fields.

      Sometimes, for whatever reason, it is preferred to bypass Espo's built in field validation rules to avoid triggering the "Field Validation Error" message and interrupting the back end program flow. Fortunately, this is now possible using metadata settings, so it is not necessary to do any coding to accomplish this.

      Comment


      • #4
        I missed your provided payload. Try passing "costPriceCurrency": "USD" in your payload. Use the currency you need instead of USD.

        Comment


        • #5
          Thanks!

          I created a workflow that added costPrice 0 if costPrice was empty on creation but sending costPriceCurrency is working and the correct solution. Thanks both of you.

          Comment

          Working...
          X