How to create a portal memo in a C4C ticket with the SAP ODATA API
2023-11-15 16:53:31 Author: blogs.sap.com(查看原文) 阅读量:4 收藏

Creating a memo/portal activity in C4C using the ODATA API supplied by SAP is more difficult and less intuitive than one would hope. After spending many days trying multiple post calls, I now have the solution and would like to share it.

First, you should ensure you have the authorizations for the API set up correctly, I suggest tetsing this on the postman.com website. Four successive POST requests are then required, I have opted to use a JSON body, XML is also accepted with some adaptations to the requests.

Hint: sensitive data has been censored with “______”. Please enter your own information here. All other data can be taken directly from the code snippits.

1.Make the following POST call to ActivityCollection:

https://my.______crm.ondemand.com/sap/c4c/odata/v1/c4codataapi/ActivityCollection

This post call should be made with the following body.

(The SubjectName should be the title of the portal memo you wish to make):

{
"PriorityCode": "3",
"SubjectName": "______",
"LifeCycleStatusCode": "1" ,
"InitiatorCode": "2"
}

2.Make the following POST call to MemoActivityBusinessTransactionDocumentReferenceCollection:

 https://my______.crm.ondemand.com/sap/c4c/odata/v1/c4codataapi/MemoActivityBusinessTransactionDocumentReferenceCollection

This post call should be made with the following body.

(The ParentObjectID can be read from the result of the previous call to ActivityCollection).

(The ID is the ticket number you wish to add a memo to):

{
                "ParentObjectID": "______",
                "ID": "______",
                "TypeCode": "118",
                "RoleCode": "1"
}

3.Make the following POST call to MemoActivityPartyCollection:

https://my______.crm.ondemand.com/sap/c4c/odata/v1/c4codataapi/MemoActivityPartyCollection

This post call should be made with the following body.

(The ParentObjectID can be read from the result of the first call to ActivityCollection).

(The PartyID is the ID of the contact/employee who should be the “creator” of the post. You can find this infomration in C4C):

{
                "ParentObjectID": "______",
                "PartyID": "______",
                "PartyTypeCode": "147",
                "RoleCode": "33"
}

4.Make the following POST call to MemoActivityTextCollection:

https://my______.crm.ondemand.com/sap/c4c/odata/v1/c4codataapi/MemoActivityTextCollection

This post call should be made with the following body.

(The ParentObjectID can be read from the result of the first call to ActivityCollection).

(The AuthorUUID is the UUID of the contact/employee who should be the “creator” of the post. You can find this information by making a post request to ContactCollection – see step 5).

(FormattedText should be the same as Text)

{
                "ParentObjectID": "______",
                "Text": "This note was created via the ODATA API",
                "LanguageCode": "EN",
                "TypeCode": "10011",
                "AuthorUUID": "______",
                "FormattedText": "This note was created via the ODATA API",
                "languageCode": "EN"
}

5.(Optional).

This step is a get request in order to find the AuthorUUID of a given contact. To do this, you will need the email address of the contact registered to c4c. Simply make the following request, replacing the email address:

https://my______.crm.ondemand.com/sap/c4c/odata/v1/c4codataapi/ContactCollection?$format=xml&[email protected]

All the best,

Jonas


文章来源: https://blogs.sap.com/2023/11/15/how-to-create-a-portal-memo-in-a-c4c-ticket-with-the-sap-odata-api/
如有侵权请联系:admin#unsafe.sh