Code Monkey home page Code Monkey logo

xrm.crm.webapi's People

Contributors

rafaelcavazza avatar zaha avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar  avatar

xrm.crm.webapi's Issues

(Batch) Activate or Close Quotes

Hi @RafaelCavazza

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.

Retrieve by Alternate Key

The current 'Retrieve' method only works with the entityId.

RetrieveAsync (string entityName, Guid entityId, params string[] properties)

Load EntityDefinitions and RelationshipDefinitions

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

image

Naming Error

Entity method "Contais" is wrong.
Must be "Contains"

Cast to Guid GetAttributeValue

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>.

Work with OptionSets

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

Unit Tests are failing

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 ms

Message:
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'.

Duplicated Attributes

For some reason the Api returns the attribute as a entity reference and
a null value.
Ex.:
image

Implement 'Execute' for the Remaining Methods

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 :)

Issues updating EntityReference in a Record

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, Action2 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

Alternate key formatting

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') ->

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.