Invalid Parameter : Custom Endpoint

I am new to sugarCRM
I had created a custom module(source IP) called order and its working fine. And I had created a custom API for the order module and I exposed that endpoint to different application in different server. The API was tested using Postman and was working fine. Whenever application (destination ip) hits order API in sugarCRM.,SugarCRM is throwing invalid parameter(error code 422) .
Below is the response
{"error":"invalid_parameter","error_message":"A parameter in your request was invalid." }
Version used is 10.3 (Enterprise)

How to solve this problem ?

Parents Reply
  • In such case,

    Since the Custom API is working fine in Postman it should work fine in your application also. It is clear that there is no issue with the Custom API you have written in Sugar.

    The error code 422 will only thrown when you miss some parameters in API or there may some syntax error in the request body.

    It would be more helpful to understand the issue if you share the XML of you request with request body. Also share the XML with request body you have given for POST /Accounts (Stock API). It would more easier to debug by comparing the stock and custom APIs.

    Thank You, 
    Vamshi S. 

Children
  • Hi 

    Below is my XML headers and JSON request for custom module (order) and Stock module(accounts)


    Request Body update order :

    {
      "o_id": "54",
      "custAccount": "C60"
    }


    XML Headers update order :

    <propertyMap>
    <property>
    <name>Request-Line</name>
    <value>PUT /sugarcrm/rest/v10/Ord_Orders/UpdateOrderMethod HTTP/1.1</value>
    </property>
    <property>
    <name>Cookie</name>
    <value>PHPSESSID=aec8062hn4rq7b7797ov5aqp2s; path=/</value>
    </property>
    <property>
    <name>Authorization</name>
    <value>Bearer 9babc467-f6ab-41ad-80ca-8c7ef5d28c59</value>
    </property>
    <property>
    <name>Accept</name>
    <value>application/json</value>
    </property>
    <property>
    <name>Host</name>
    <value>ip address comes here</value>
    </property>
    <property>
    <name>Content-Type</name>
    <value>application/json; charset=ISO-8859-1</value>
    </property>
    </propertyMap>



    Request Body for accounts :

    {
      "name": "Customer Account07",
      "account_type": "Customer Account",
      "phone_office": "12345678",
      "email": "abc@xyz.com",
      "salutation_c": "Ms.",
      "username_c": "Abc",
      "lastname_c": "Xyz",
      "active_cart_id_c": "123456",
      "bel_customer_id_c": "543678"
    }


    XML headers for accounts :

    <propertyMap>
    <property>
    <name>Request-Line</name>
    <value>POST /sugarcrm/rest/v10/Accounts HTTP/1.1</value>
    </property>
    <property>
    <name>Cookie</name>
    <value>PHPSESSID=bmc7frtmkq70c957gkm1v2v4sl; path=/</value>
    </property>
    <property>
    <name>Authorization</name>
    <value>Bearer e215b865-2d52-4cc3-ab22-2c620f33b55e</value>
    </property>
    <property>
    <name>Accept</name>
    <value>application/json</value>
    </property>
    <property>
    <name>Host</name>
    <value>ip address here</value>
    </property>
    <property>
    <name>Content-Type</name>
    <value>application/json; charset=ISO-8859-1</value>
    </property>
    </propertyMap>