This topic contains 0 replies, has 1 voice, and was last updated by arlt.tomas 6 years, 8 months ago.
- Topic
Hello,
I have a problem. I want to create, get, .. emails from the orocrm api. First when I opened api/doc/rest_json_api I didn’t see anything related with emails. Then I found that oro added automatic generation of api since June 2016. So I edited the api.yml in the EmailBundle. To this:
1234567891011121314151617181920212223242526272829303132333435363738394041424344454647api:entities:# Oro\Bundle\EmailBundle\Entity\EmailTemplate: ~# Oro\Bundle\EmailBundle\Entity\AutoResponseRule: ~# Oro\Bundle\EmailBundle\Entity\AutoResponseRuleCondition: ~Oro\Bundle\EmailBundle\Entity\Email:documentation_resource: '@OroEmailBundle/Resources/doc/api/email.md'fields:activityTargets:data_type: association:manyToMany:activityactions:get: trueget_list: trueupdate: truecreate: truedelete: truedelete_list: falseget_relationship: trueupdate_relationship: trueadd_relationship: truedelete_relationship: truesubresources:recipients: truesuggestions:target_class: Oro\Bundle\ApiBundle\Model\EntityIdentifiertarget_type: collectionactions:get_relationship: trueupdate_relationship: trueadd_relationship: truedelete_relationship: truefilters:fields:exclude-current-user:data_type: booleanOro\Bundle\EmailBundle\Entity\EmailAttachment: ~Oro\Bundle\EmailBundle\Entity\EmailAttachmentContent: ~Oro\Bundle\EmailBundle\Entity\EmailBody: ~Oro\Bundle\EmailBundle\Entity\EmailFolder: ~Oro\Bundle\EmailBundle\Entity\EmailOrigin: ~Oro\Bundle\EmailBundle\Entity\EmailRecipient: ~Oro\Bundle\EmailBundle\Entity\EmailThread: ~Oro\Bundle\EmailBundle\Entity\EmailUser: ~# Oro\Bundle\EmailBundle\Entity\InternalEmailOrigin: ~Oro\Bundle\EmailBundle\Entity\Mailbox: ~I also tried just putting there: Oro\Bundle\EmailBundle\Entity\Email: ~
It worked but I think it is not showing everything. F.e. when I tried to add a new email. Through sandbox on api/emails POST with following content:1234567891011121314151617181920212223{"data":{"type": "emails","attributes": {"created": "2017-08-17T12:51:04Z","subject": "test","fromName": "test","sentAt": "2017-08-17T12:51:04Z","importance": 1,"internalDate": "2017-08-17T12:51:04Z","head": true,"messageId": "test","multiMessageId": null,"xMessageId": null,"xThreadId": null,"refs": [],"acceptLanguageHeader": null,"bodySynced": false}}}I got following error:
123456789{"errors": [{"status": "500","title": "not null constraint violation exception","detail": "*DEBUG ONLY* An exception occurred while executing 'INSERT INTO oro_email (serialized_data, created, subject, from_name, sent, importance, internaldate, is_head, message_id, multi_message_id, x_message_id, x_thread_id, refs, acceptLanguageHeader, body_synced, thread_id, email_body_id, from_email_address_id) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)' with params [\"Tjs=\", \"2017-08-17 12:51:04\", \"test\", \"test\", \"2017-08-17 12:51:04\", 1, \"2017-08-17 12:51:04\", 1, \"test\", null, null, null, null, null, 0, null, null, null]:\n\nSQLSTATE[23502]: Not null violation: 7 ERROR: null value in column \"from_email_address_id\" violates not-null constraint\nDETAIL: Failing row contains (4, null, null, null, 2017-08-17 12:51:04, test, test, 2017-08-17 12:51:04, 1, 2017-08-17 12:51:04, test, null, null, t, null, null, null, f, Tjs=)."}]}I know what it means, but I haven’t seen any atribute in api/doc which I could set to connect the email with the address. Even I haven’t found relationships for email adresses.
I think that it is not generating the api correctly. Because even if I would like to create a Email with attachment. The correct way of doing it (looked in to the entity model). Is to create EmailBody which can add EmailAttachment and EmailBody is then added to Email. The problem is that I can’t see EmailBody in the api/doc/rest_json_api even though it is enabled in the api.yml.
Does somebody please know how to resolve this problem? Thank you :)
The forum ‘OroPlatform – How do I? Questions’ is closed to new topics and replies.