Announcement

Collapse
No announcement yet.

API Post CRUD HTTP

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

  • API Post CRUD HTTP

    Anyone having trouble with EspoCRM sending API POST request? I been trying all day but it keep failing with 404. I have no issue getting GET and PUT to work but it keep failing with POST.

    My content is already added with the ContentType: application/json

    I tested both my version, and then go to the demo and create API User (default create setting) but same issue with POST. If anyone can guide me, or do a test if you getting same error or able to get a POST working that would be great.

    I'm currently working on something I find very interesting and hopefully this will work once I get the POST to work.

  • #2
    Hello man,

    It is probably caused by missing "required" field in the request payload.

    Check ESPO Logs (/data/logs) for more information. When API request POST fails, usually you get the error log with more information.

    I worked with API post request last week and I had similar problem, but once I added the required field into the payload the error was gone

    The error I was getting.
    Code:
    [2023-03-30 06:55:53] ERROR: (400) Field validation failure; entityType: Lead, field: pozadovanyVykon, type: required.; POST /Lead; line: 54, file: /data/3/3/338fc1b6-ecde-4497-89be-33f005571989/esmerofve.eu/web/application/Espo/Core/Exceptions/BadRequest.php [] []
    Hope it helps.
    Cheers

    Comment


    • #3
      404 is likely non existing API endpoint. Check Espo logs, maybe set the log level to NOTICE to see more.

      For more help, more details needed. What exactly do you call.

      Comment


      • #4
        OK. I manage to get some of it to work with the hints above. I'm still trying to get it to work. Sometime it working, sometime it got a 404 error. So I'm not sure what blocking it.

        But I will keep trying until a solution is found and I will post result of effort.

        Comment


        • #5
          OK, manage to make some progress, but how do I fix this problem?

          dateStart? It look like only YYYY-MM-DD HH:MM:SS time is accepted? The other App I'm using seem to be using Unix Epoch(?) time so I'm getting a validation error at the moment.

          Comment


          • #6
            Convert it to YYYY-MM-DD HH:MM:SS on the calling side.

            Comment


            • Jakub Grufik
              Jakub Grufik commented
              Editing a comment
              thats what I would suggest, however, it is not easy to achieve if you are just using third-party app that sends API calls and you have no access to the code..

          • #7
            Hi Jakub Grufik
            Yes that is true! That why I ask if there is any other method.

            Thankfully the webhook/API service I do have this feature! Fortunately with tutorial and guide I manage to get it to work. I'm currently documenting my adventure on here if this is something you want to try to do or do it for yourself.

            There is still bug at the moment as I try to resolve, might take few hours learning as well. Basically it doesn't work for any multi-lines \n type. So I probably need to do the same thing. Convert it somehow...

            Since I'm a code newbie I probably just create another Code section with the same concept. Anyway if you have any input or success, please do share.

            In the future this thread will be use for discussion; the Wiki hosted on Github will be used instead to post update; please see: https://github.com/o-data/EspoCRM-Learning-and-Design/wiki Part 2 of this post can be found here: https://forum.espocrm.com/forum/gene...5114#post55114 (https://forum.espocrm.com/forum/general/54706

            Comment


            • #8
              Hi guys,

              Anyone know how to POST Meeting entity?

              I'm getting stuck with this "Type" field and can't get the JSON to work. I checked all field and disable Required validation but no luck. From what I see, only Name is required.

              From a "GET" I can see the following JSON with the word "type" but currently failing. If anyone can share a very basic simple working JSON for Meeting that be appreciated.

              Code:
              "reminders":[{seconds:":1800,"type":"Popup"}]
              Perhaps the code is correct but I'm using HTTP CRUD wrong? Thank you.

              Comment


              • esforim
                esforim commented
                Editing a comment
                One of the error:

                {"messageTranslation":{"label":"validatationFailur e","scope":null,"data":{"field":"reminders","type" :"valid"}}}

                So look up I;m still doing something wrong with the code.

            • #9
              "seconds:" => seconds"

              Comment


              • #10
                Thank you Boss yuri . Look like I finally got it to work!

                Also realized that I can disable assigneduserID as a required field... that save some more trouble.

                ---

                For late reader, you can read my Learning Thread for guide/tutorial. Working on SMS incoming, outgoing, Call and Meeting/Calendar.

                Once I get Task to work (hopefully) then I can finally create a 'poor-code' version of Mobile App.

                Comment

                Working...
                X