2017-10-03 49 views
6

CRM 2016 hiển thị odata/web api và có functionsactions ra khỏi hộp.cách nhận tài nguyên sẵn có bằng cách sử dụng api web?

Với dịch vụ tổ chức, chúng tôi có thể đưa ra một yêu cầu like this:

// Create the van required resource object. 
RequiredResource vanReq = new RequiredResource 
{ 
    ResourceId = _vanId, 
    ResourceSpecId = _specId 
}; 

// Create the appointment request. 
AppointmentRequest appointmentReq = new AppointmentRequest 
{ 
    RequiredResources = new RequiredResource[] { vanReq }, 
    Direction = SearchDirection.Backward, 
    Duration = 60, 
    NumberOfResults = 10, 
    ServiceId = _plumberServiceId, 
    // The search window describes the time when the resouce can be scheduled. 
    // It must be set. 
    SearchWindowStart = DateTime.Now.ToUniversalTime(), 
    SearchWindowEnd = DateTime.Now.AddDays(7).ToUniversalTime(), 
    UserTimeZoneCode = 1 
}; 

// Verify whether there are openings available to schedule the appointment using this resource    
SearchRequest search = new SearchRequest 
{ 
    AppointmentRequest = appointmentReq 
}; 
SearchResponse searched = (SearchResponse)_serviceProxy.Execute(search); 

if (searched.SearchResults.Proposals.Length > 0) 
{ 
    Console.WriteLine("Openings are available to schedule the resource."); 
} 

Có thể bắt chước chức năng này sử dụng các chức năng/hành động hay bất kỳ chức năng OData khác?

Tôi tin rằng yêu cầu nên một cái gì đó như thế này:

crmOrg/api/v8.1/Search([email protected])[email protected]= 

Tuy nhiên, tôi không chắc chắn làm thế nào để mã hóa các phần còn lại của yêu cầu.

+0

'_serviceProxy.Execute' sẽ gửi yêu cầu qua' http' (tcp port 80) đến điểm cuối (sử dụng HTTP GET) . Bạn có thể chụp yêu cầu này trên PC của mình bằng trình quét mạng hoặc với công cụ gỡ lỗi. Tôi thích [Fiddler] (http://www.telerik.com/fiddler), bạn có thể định cấu hình này làm proxy giữa ứng dụng của bạn và điểm kết thúc và nó sẽ thu hút lưu lượng truy cập. Sau đó, nó chỉ là vấn đề đọc URL cho từng yêu cầu cụ thể mà bạn muốn bắt chước. Vì vậy, tạo yêu cầu trong C# và chụp URL được tạo trong Fiddler (* nó cũng là một công cụ miễn phí, tôi không có liên kết với telerik *). – Igor

+0

Có lẽ bạn có thể soạn fetchxml & phát hành cuộc gọi api trên web như sau: https://community.dynamics.com/crm/b/mscrmcustomization/archive/2016/11/01/use-fetchxml-to-retrieve-data- từ-ms-crm-2016-sử dụng-web-api –

Trả lời

2

Tham số đi như thế:

http://yourcrm.org/org/api/data/v8.1/Search([email protected])/[email protected]={SearchWindowStart:%272017-01-01%27,Duration:60,NumberOfResults:10} 

nó là url mã hóa json của serialized lớp AppointmentRequest.

{ 
    SearchWindowStart:'2017-01-01', 
    Duration: 60, 
    NumberOfResults:10, 
    etc... 
} 

Thông tin thêm ở đây: https://msdn.microsoft.com/en-us/library/microsoft.crm.sdk.messages.appointmentrequest.aspx

OData tham khảo: http://odata.github.io/WebApi/04-06-function-parameter-support/

Các vấn đề liên quan