CRM V2 API is able to create a record entry even when required fields are left empty.
I have created an `Orders` custom module as follows:
As you can see, the `random` field is marked as `required` field.
When I edit an order on the crm, as expected, it does not allow me to save the form when I leave these fields blank (screenshot below).
Now the problem is, when I use the API to upsert (create / update) orders, it allows me to leave these fields blank.
- orders = [
- {
- random: "",
- platform_order_id: "order_id_3",
- customer_details: [{
- email: "abc@abc.com",
- phone_number: "1111111111"
- }],
- Name: "DELEETEME",
- shipping_address: [{
- city: "Metro",
- postal_code: nil
- }]
- },
- {
- random: "123",
- platform_order_id: "order_id_1",
- customer_details: [{
- email: "abc@abc.com",
- phone_number: "1111111111"
- }],
- Name: "01422#AB",
- shipping_address: [{
- city: "Metro",
- postal_code: 011233
- }]
- },
- {
- random: nil,
- platform_order_id: "order_id_2",
- customer_details: [{
- email: "abc@abc.com",
- phone_number: "11111111"
- }],
- Name: "01433#Ac",
- shipping_address: [{
- city: "Metro",
- postal_code: ""
- }]
- }
- ]
- response = HTTParty.post("https://www.zohoapis.in/crm/v2/Orders/upsert", {
- headers: {
- "Content-Type": "application/json",
- Authorization: "Zoho-oauthtoken #{ACCESS_TOKEN}"
- },
- body: {
- data: orders.as_json,
- duplicate_check_fields: ["Name"]
- }.to_json
- })
The above payload successfully creates / updates 3 records. Response JSON is as follows:
- {
- "data": [
- {
- "code": "SUCCESS",
- "duplicate_field": null,
- "action": "insert",
- "details": {
- "Modified_Time": "2021-12-22T13:23:06+05:30",
- "Modified_By": {
- "name": "haris ",
- "id": "273355000000207001"
- },
- "Created_Time": "2021-12-22T13:23:06+05:30",
- "id": "273355000000259001",
- "Created_By": {
- "name": "haris ",
- "id": "273355000000207001"
- }
- },
- "message": "record added",
- "status": "success"
- },
- {
- "code": "SUCCESS",
- "duplicate_field": "Name",
- "action": "update",
- "details": {
- "Modified_Time": "2021-12-22T13:23:07+05:30",
- "Modified_By": {
- "name": "haris ",
- "id": "273355000000207001"
- },
- "Created_Time": "2021-12-22T11:37:55+05:30",
- "id": "273355000000254004",
- "Created_By": {
- "name": "haris ",
- "id": "273355000000207001"
- }
- },
- "message": "record updated",
- "status": "success"
- },
- {
- "code": "SUCCESS",
- "duplicate_field": "Name",
- "action": "update",
- "details": {
- "Modified_Time": "2021-12-22T13:23:07+05:30",
- "Modified_By": {
- "name": "haris ",
- "id": "273355000000207001"
- },
- "Created_Time": "2021-12-22T11:37:55+05:30",
- "id": "273355000000254007",
- "Created_By": {
- "name": "haris ",
- "id": "273355000000207001"
- }
- },
- "message": "record updated",
- "status": "success"
- }
- ]
- }
Is this the expected behaviour via the API? Does this mean that marking fields as "required" is not respected while creating / updating records via the API?