CRM公开actions,它允许您通过Web API执行它们。
例如,以下是class JSONSerializerField(serializers.Field):
"""Serializer for JSONField -- required to make field writable"""
def to_representation(self, value):
json_data = {}
try:
json_data = json.loads(value)
except ValueError as e:
raise e
finally:
return json_data
def to_internal_value(self, data):
return json.dumps(data)
class AnyModelSerializer(serializers.ModelSerializer):
field = JSONSerializerField()
class Meta:
model = SomeModel
fields = ('field',)
操作架构和API:
WinOpportunity
要执行此问题,您可以发布以下内容:
<Action Name="WinOpportunity">
<Parameter Name="OpportunityClose" Type="mscrm.opportunityclose" Nullable="false" />
<Parameter Name="Status" Type="Edm.Int32" Nullable="false" />
</Action>
有没有办法执行BookRequest操作?
在检查CSDL架构时,我发现此操作定义为:
POST [Organization URI]/api/data/v8.2/WinOpportunity HTTP/1.1
Accept: application/json
Content-Type: application/json; charset=utf-8
OData-MaxVersion: 4.0
OData-Version: 4.0
{
"Status": 3,
"OpportunityClose": {
"subject": "Won Opportunity",
"opportunityid@odata.bind": "[Organization URI]/api/data/v8.2/opportunities(b3828ac8-917a-e511-80d2-00155d2a68d2)"
}
}
此图书操作的请求会是什么样?
答案 0 :(得分:1)
参考MSDN,BookRequest
消息期望Appointment
为Target
。 Book也可以采取行动。
// Create the ActivityParty instance.
ActivityParty party = new ActivityParty
{
PartyId = new EntityReference(SystemUser.EntityLogicalName, userResponse.UserId)
};
// Create the appointment instance.
Appointment appointment = new Appointment
{
Subject = "Test Appointment",
Description = "Test Appointment created using the BookRequest Message.",
ScheduledStart = DateTime.Now.AddHours(1),
ScheduledEnd = DateTime.Now.AddHours(2),
Location = "Office",
RequiredAttendees = new ActivityParty[] { party },
Organizer = new ActivityParty[] { party }
};
// Use the Book request message.
BookRequest book = new BookRequest
{
Target = appointment
};
参考MSDN,webapi请求可能如下所示:(使用现有约会记录,仍然收到400 Bad请求)
POST [Organization URI]/api/data/v8.2/Book HTTP/1.1
Accept: application/json
Content-Type: application/json; charset=utf-8
OData-MaxVersion: 4.0
OData-Version: 4.0
{
"Target": {
"activityid": "59ae8258-4878-e511-80d4-00155d2a68d1",
"@odata.type": "Microsoft.Dynamics.CRM.appointment"
}
}