rafaelcavazza / xrm.crm.webapi Goto Github PK
View Code? Open in Web Editor NEWLicense: MIT License
License: MIT License
I tried to activate and close a quote, but I always get the following error:
[19.08.2019 11:45:05] System.Private.CoreLib: Exception while executing function: CloseNeglectedOpportunitiesAsLost. Xrm.Crm.WebApi: Error occurred and no handler is available for content in the multipart/mixed format.
Am I doing somethring wrong here?
var batchRequest = new BatchRequest();
foreach (Guid quoteId in currentBatch)
{
var activateQuote = new Entity("quote", quoteId);
activateQuote["statecode"] = (int)QuoteState.Active;
activateQuote["statuscode"] = (int)Quote_StatusCode.InProgress_Active;
batchRequest.AddRequest(new UpdateRequest(activateQuote));
}
BatchRequestResponse response = await webApi.ExecuteBatchRequestAsync(batchRequest);
Or is this operation not supported yet? I am not quite sure how this is supposed to work with the Web API. I found one source stating that you are supposed to use the Update Request for that kind of operation now and then I found special actions just for Win Quote and Revise Quote in the Web API doc.
Would need to know the same for winning/losing opportunities, but I assume this is similar.
The current 'Retrieve' method only works with the entityId.
RetrieveAsync (string entityName, Guid entityId, params string[] properties)
Implement HttpClient mock to better test the project.
Add a option to load the EntityDefinitions with Attributes and the RelationshipDefinitions.
With those loaded we can auto correct attributes names and entity relationships.
Ex. ->
entity["new_account"]
is corrected to -> entity["new_Account"]
Api Links:
/api/data/v8.2/EntityDefinitions?$filter=SchemaName eq 'ENTITY_NAME' & $expand=Attributes
/api/data/v8.2/EntityDefinitions?$expand=Attributes
/api/data/v8.2/RelationshipDefinitions(SchemaName='ENTITY_SCHEMANAME')
/api/data/v8.2/RelationshipDefinitions
Ex.:
When creating a Incident with the customer field:
entity["customerid"] = new EntityReference("contact", new Guid())
Must be changed by the Api To ->
entity["customerid_contact"] = new EntityReference("contact", new Guid())
The RelationshipDefinitions contains the 'ReferencingEntityNavigationPropertyName' with the correct value
Entity method "Contais" is wrong.
Must be "Contains"
When there is a Guid attribute the API returns a string. This causes an error when using: entity.GetAttributeValue<Guid>("ATTRIBUTE").
Implement a String to Guid conversion in GetAttributeValue<T>
.
There is a bug in the RetrieveOptions
:
if (!string.IsNullOrWhiteSpace(Filter))
query["$filter"] = FetchXml;
It's using the FetchXml
parameter instead of Filter
.
Hi @RafaelCavazza,
I just found your library and am liking the API. I'm trying to set an option set value for a lead and couldn't find any OptionSet class or example in the UnitTests. How do I set an optionset value?
Cheers
Michael
I noticed that some unit tests relying on a file are broken now:
Xrm.Crm.WebApi.Test.QualifyLeadResponseFormatterTest.FormatResponseTest
Source: QualifyLeadResponseFormatterTest.cs line: 16
Duration: 1 msMessage:
System.IO.DirectoryNotFoundException : Could not find a part of the path '...\Xrm.Crm.WebApi\dotnet\Xrm.Crm.WebApi.Test\bin\Debug\netcoreapp2.2\TestFiles\QualifyResponse.json'.
{
"description" : "",
"subject" : "",
"email_activity_parties" :
[
{
"addressused" : "[email protected]",
"participationtypemask" : 1
}
],
"overriddencreatedon":"2017-01-01T00:00:00Z"
}
Create CRUD examples
There are still some methods that need to be converted for the 'Execute' pattern.
In the docs there are a lot of Actions/Functions.
I believe we can provide some mechanisms that enable the developer to execute custom call even if they are not implemented.
Perhaps exposing the current HttpCliente or some Interface tha can be implemente.
@zaha any help or thoughts are welcome :)
Chave alternativa não faz upsert e nem retorna erro utilizando caracteres especiais.
Ex.
: /
Hi @RafaelCavazza,
I tried to update a Lead entity that has two custom Lookup fields for an entity called tv_Language
like so:
var lead = new Entity("lead");
var language = new EntityReference("tv_language", new Guid("3D722FCA-7FB9-E711-80EC-3863BB34C940");
lead["tv_language"] = language;
lead["tv_spokenlanguage"] = language;
Guid guid = await webApi.CreateAsync(lead);
But when I do so, I receive the following exception:
Can not add property [email protected] to Newtonsoft.Json.Linq.JObject. Property with the same name already exists on object.
StackTrace:
at Newtonsoft.Json.Linq.JObject.ValidateToken(JToken o, JToken existing)
at Newtonsoft.Json.Linq.JContainer.InsertItem(Int32 index, JToken item, Boolean skipParentCheck)
at Xrm.Crm.WebApi.Request.RequestEntityParser.EntityToJObject(Entity entity, WebApiMetadata webApiMetadata) in D:\Workspace\GitHub\Xrm.Crm.WebApi\dotnet\Xrm.Crm.WebApi\Request\RequestEntityParser.cs:line 19
at Xrm.Crm.WebApi.WebApi.CreateAsync(Entity entity) in D:\Workspace\GitHub\Xrm.Crm.WebApi\dotnet\Xrm.Crm.WebApi\WebApi.cs:line 42
at TeamViewer.SalesLeads.CrmWebApi.SalesLeadRepository.CreateAsync(WebFormLead webFormLead) in D:\Workspace\D365\Web Services\Sales Leads Service\Persistence\TeamViewer.SalesLeads.CrmWebApi\SalesLeadRepository.cs:line 51
at TeamViewer.SalesLeads.TestConsole.Program.MainAsync() in D:\Workspace\D365\Web Services\Sales Leads Service\Presentation\TeamViewer.SalesLeads.TestConsole\Program.cs:line 58
at TeamViewer.SalesLeads.TestConsole.Program.Main(String[] args) in D:\Workspace\D365\Web Services\Sales Leads Service\Presentation\TeamViewer.SalesLeads.TestConsole\Program.cs:line 23
After a little bit of investigation I found that every type of entityreference is added to a dictionary, so if you have two lookup fields for the same entity type it will cause a duplicate key exception. Therefore, I uncommented one of the two lines but I still got an exception:
An error occurred while validating input parameters: Microsoft.OData.ODataException: An undeclared property 'tv_languages' which only has property annotations in the payload but no property value was found in the payload. In OData, only declared navigation properties and declared named streams can be represented as properties without values.
at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadUndeclaredProperty(IODataJsonLightReaderResourceState resourceState, String propertyName, Boolean propertyWithValue)
at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadPropertyWithoutValue(IODataJsonLightReaderResourceState resourceState, String propertyName)
at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.<>c__DisplayClass4_0.b__0(PropertyParsingResult propertyParsingResult, String propertyName)
at Microsoft.OData.JsonLight.ODataJsonLightDeserializer.ProcessProperty(PropertyAndAnnotationCollector propertyAndAnnotationCollector, Func2 readPropertyAnnotationValue, Action
2 handleProperty)
at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadResourceContent(IODataJsonLightReaderResourceState resourceState)
at Microsoft.OData.JsonLight.ODataJsonLightReader.ReadResourceStart(PropertyAndAnnotationCollector propertyAndAnnotationCollector, SelectedPropertiesNode selectedProperties)
at Microsoft.OData.JsonLight.ODataJsonLightReader.ReadAtStartImplementationSynchronously(PropertyAndAnnotationCollector propertyAndAnnotationCollector)
at Microsoft.OData.ODataReaderCore.ReadImplementation()
at Microsoft.OData.ODataReaderCore.InterceptException[T](Func`1 action)
at System.Web.OData.Formatter.Deserialization.ODataReaderExtensions.ReadResourceOrResourceSet(ODataReader reader)
at System.Web.OData.Formatter.Deserialization.ODataResourceDeserializer.Read(ODataMessageReader messageReader, Type type, ODataDeserializerContext readContext)
at System.Web.OData.Formatter.ODataMediaTypeFormatter.ReadFromStream(Type type, Stream readStream, HttpContent content, IFormatterLogger formatterLogger)StackTrace:
at Xrm.Crm.WebApi.Response.ResponseValidator.EnsureSuccessStatusCode(HttpResponseMessage response, String jsonData) in D:\Workspace\GitHub\Xrm.Crm.WebApi\dotnet\Xrm.Crm.WebApi\Response\ResponseValidator.cs:line 30
at Xrm.Crm.WebApi.WebApi.CreateAsync(Entity entity) in D:\Workspace\GitHub\Xrm.Crm.WebApi\dotnet\Xrm.Crm.WebApi\WebApi.cs:line 48
at TeamViewer.SalesLeads.CrmWebApi.SalesLeadRepository.CreateAsync(WebFormLead webFormLead) in D:\Workspace\D365\Web Services\Sales Leads Service\Persistence\TeamViewer.SalesLeads.CrmWebApi\SalesLeadRepository.cs:line 51
at TeamViewer.SalesLeads.TestConsole.Program.MainAsync() in D:\Workspace\D365\Web Services\Sales Leads Service\Presentation\TeamViewer.SalesLeads.TestConsole\Program.cs:line 58
at TeamViewer.SalesLeads.TestConsole.Program.Main(String[] args) in D:\Workspace\D365\Web Services\Sales Leads Service\Presentation\TeamViewer.SalesLeads.TestConsole\Program.cs:line 23
Am I doing something fundamentally wrong here or is this a bug?
Cheers
Michael
When using the alternate key the value must be formatted.
Ex.:
/api/data/v8.2/accounts(alternatekey='teste 'teste') ->
/api/data/v8.2/accounts(alternatekey='teste ''teste') ->
Hi,
Do you intend for these NuGet packages to also be under the MIT license - https://www.nuget.org/packages/Xrm.Crm.WebApi/?
Thanks,
Ariel
A declarative, efficient, and flexible JavaScript library for building user interfaces.
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google ❤️ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.