API v8 how to create new registers

Hello, i 'm trying to learn how to use the new API V8.

I can recieve information but cant create new registers.
the documentation seems incorrect “POST /api/v8/modules/{module}/{id}” because there is no id yet.
there are no examplet neither.
I found some viedos from sugarCRM API but they does’t work.

Where can I found some examples or information about the objetct that need to be sent?

Thank you

When you create a new record using POST just use /api/v8/modules/{module}

Here’s a very simple example:

POST v8/modules/EmailAddresses
{'data': {'attributes': {'email_address': 'test@test.com',
                         'email_address_caps': 'TEST@TEST.COM'},
                         'type': 'EmailAddresses'}}

Is there a way to post more? Like this?

POST v8/modules/EmailAddresses
{'data': [{'attributes': {'email_address': 'test@test.com',
                         'email_address_caps': 'TEST@TEST.COM'},
                         'type': 'EmailAddresses'},
{'attributes': {'email_address': 'test1@test.com',
                         'email_address_caps': 'TEST1@TEST.COM'},
                         'type': 'EmailAddresses'}]}

Well I think that COULD work, give it a try :slight_smile:

It doesn’t… I tried like everything I could think of :frowning: I need to bulk create like 12 tasks per project and I can’t do it like this… Have to go one by one…

For example:

{
   "data": 	[{
   	  "type": "ProjectTask",
   	  "attributes": {
         "name": "FinalTask02"
      }
   },
   {
   	  "type": "ProjectTask",
   	  "attributes": {
         "name": "FinalTask03"
      }
   }]
} 

When I send this as a POST to {{url}}/V8/module it returns:

{
    "errors": {
        "status": 400,
        "title": null,
        "detail": "The options \"0\", \"1\" do not exist. Defined options are: \"attributes\", \"id\", \"type\"."
    }
}

:S :frowning:

If I only send one project task it creates it OK… I am on v. 7.11.2… Not sure if I should update to the latest 7.11.3…maybe it solves it…

It could be that the current API doesn’t support “bulk” creation… I’d check the code directly

Ehhh…thats not good at all though… I need to import like 50 to 200 projects a day and each one should have like 17 pre-defined tasks… But as I understand I can’t use project templates through API…? I have a templates that create those project tasks automatically but it doesnt work for me through API…

Anyway…thank you for your response :slight_smile: