Skip to main content

How to Fix ACCESS_DENIED Errors on REST API CREATE Operations (API)

Purpose: This guide helps resolve ACCESS_DENIED errors when attempting to create records via the Dazos REST API, even when authentication and read operations work correctly.

Symptom/Error

You receive an ACCESS_DENIED error when attempting to create records through the REST API, despite successful authentication and working SELECT or ListTypes operations.

Caption: Example of the error returned when the API rejects the request format.


Root Cause

The underlying Vtiger Webservice API (webservice.php) rejects CREATE operations when they are sent as standard raw JSON bodies. The API interprets these requests as empty or unauthorized, even when the session token is valid.


Solution

To fix this error, you must change your HTTP request format from JSON to form-urlencoded.


Step 1: Change Content-Type Header

Update your POST request header:

  • From: Content-Type: application/json

  • To: Content-Type: application/x-www-form-urlencoded


Step 2: Format Payload as Form Data

Instead of sending a raw JSON body, structure your data as URL-encoded form parameters using these fields:

Key

Value

operation

create

sessionName

[Your Session Token]

elementType

[Module Name, e.g., Contacts]

element

[URL-encoded JSON string of your record data]

Step 3: Example Payload Format

Your final payload string should look like this:

operation=create&sessionName=[YourSessionToken]&elementType=Contacts&element={"lastname":"Hessler","firstname":"Sam","birthday":"1990-01-01"}


โš ๏ธ Note: Make sure the JSON string in the element parameter is properly URL-encoded!


Step 4: Include All Mandatory Fields

Ensure your record data includes all mandatory fields for the target module.

Caption: Check the module schema to ensure all required fields are included in your 'element' string.


๐Ÿ’ก Tip: Missing required fields will result in a MANDATORY_FIELDS_MISSING error rather than an Access Denied error.


When to Contact Support

Contact Dazos Support if:

  • You continue receiving ACCESS_DENIED errors after switching to form-urlencoded.

  • You are unsure which fields are mandatory for your specific module.

  • You need a screen share to troubleshoot specific implementation details.


Did this answer your question?