Skip to content

Dolibarr 20.0.1: HTTP 500 Error When Adding Supplier Prices via API #32039

Closed
@ElaaxMarketing

Description

@ElaaxMarketing

Bug

Attempting to create or update supplier prices via the Dolibarr 20.0.1 API results in a 500 Internal Server Error. Manual entry via the Dolibarr interface works correctly, but API calls with valid payload data fail consistently.

The API responds with an HTTP 500 Internal Server Error when a POST request with the payload is sent to the endpoint /products/{PRODUCT_ID}/purchase_prices.

Dolibarr Version

20.0.1

Environment PHP

8.2

Environment Database

MariaDB 11.3.2-MariaDB-1:11.3.2+maria

Steps to reproduce the behavior and expected behavior

import requests
import json

API Configuration

api_url = "https://xxxx/api/index.php/"
api_key = "xxxxxxxxxxxxxxxx"

PRODUCT_ID = 68198 # Example product ID
url = f"{api_url}products/{PRODUCT_ID}/purchase_prices"

Payload

payload = {
"qty": 1,
"buyprice": 15.99,
"price_base_type": "HT",
"fourn_id": 3,
"availability": 7,
"ref_fourn": "449452",
"tva_tx": 19.00,
"charges": "SU2411-00030",
"delivery_time_days": 2,
"supplier_reputation": "Favorit",
"desc_fourn": "string",
"barcode": "string",
"fk_barcode_type": 0
}

Headers

headers = {
"DOLAPIKEY": api_key,
"Content-Type": "application/json",
"Accept": "application/json",
}

Send POST request

response = requests.post(url, json=payload, headers=headers)

Check result

if response.status_code == 200:
print("Supplier price successfully updated.")
print(response.json())
else:
print(f"Error {response.status_code}: {response.text}")
print("Payload:")
print(json.dumps(payload, indent=4))

Attached files

Bildschirmfoto vom 2024-11-21 17-25-17
Bildschirmfoto vom 2024-11-21 17-25-32

Metadata

Metadata

Assignees

No one assigned

    Labels

    BugThis is a bug (something does not work as expected)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions