简体   繁体   中英

Postman Url create Record in Crm Dynamics

I have to create a record in a non system entity in Dynamics (ac_sejour) with Postman. I tried many kind of requests and i have a 400 Bad Request issue. example of requests that i made:

{{ressource}}/api/data/v9.2/ac_sejours OR {{ressource}}/api/data/v9.2/entities/ac_sejours

  • I put the Data Json in the body section

The error i have is the following:

"error": {
    "code": "0x0",
    "message": "Error identified in Payload provided by the user for Entity :'ac_sejours', For more information on this error please follow this help link https://go.microsoft.com/fwlink/?linkid=2195293  ---->  InnerException : Microsoft.OData.ODataException: Cannot convert the literal '11122223333' to the expected type 'Edm.String'. ---> Microsoft.OData.ODataException: Cannot convert a value of type 'Edm.Decimal' to the expected target type 'Edm.String'.\r\n   at Microsoft.OData.ODataPayloadValueConverter.ConvertFromPayloadValue(Object value, IEdmTypeReference edmTypeReference)\r\n   --- End of inner exception stack trace ---\r\n   at Microsoft.OData.ODataPayloadValueConverter.ConvertFromPayloadValue(Object value, IEdmTypeReference edmTypeReference)\r\n   at Microsoft.Crm.Extensibility.ODataV4.CrmPrimitivePayloadValueConverter.ConvertFromPayloadValue(Object value, IEdmTypeReference edmTypeReference)\r\n   at Microsoft.OData.JsonLight.ODataJsonLightReaderUtils.ConvertValue(Object value, IEdmPrimitiveTypeReference primitiveTypeReference, ODataMessageReaderSettings messageReaderSettings, Boolean validateNullValue, String propertyName, ODataPayloadValueConverter converter)\r\n   at Microsoft.OData.JsonLight.ODataJsonLightPropertyAndValueDeserializer.ReadPrimitiveValue(Boolean insideJsonObjectValue, IEdmPrimitiveTypeReference expectedValueTypeReference, Boolean validateNullValue, String propertyName)\r\n   at Microsoft.OData.JsonLight.ODataJsonLightPropertyAndValueDeserializer.ReadNonEntityValueImplementation(String payloadTypeName, IEdmTypeReference expectedTypeReference, PropertyAndAnnotationCollector propertyAndAnnotationCollector, CollectionWithoutExpectedTypeValidator collectionValidator, Boolean validateNullValue, Boolean isTopLevelPropertyValue, Boolean insideResourceValue, String propertyName, Nullable`1 isDynamicProperty)\r\n   at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadEntryDataProperty(IODataJsonLightReaderResourceState resourceState, IEdmProperty edmProperty, String propertyTypeName)\r\n   at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadPropertyWithValue(IODataJsonLightReaderResourceState resourceState, String propertyName, Boolean isDeltaResourceSet)\r\n   at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.<>c__DisplayClass9_0.<ReadResourceContent>b__0(PropertyParsingResult propertyParsingResult, String propertyName)\r\n   at Microsoft.OData.JsonLight.ODataJsonLightDeserializer.ProcessProperty(PropertyAndAnnotationCollector propertyAndAnnotationCollector, Func`2 readPropertyAnnotationValue, Action`2 handleProperty)\r\n   at Microsoft.OData.JsonLight.ODataJsonLightResourceDeserializer.ReadResourceContent(IODataJsonLightReaderResourceState resourceState)\r\n   at Microsoft.OData.JsonLight.ODataJsonLightReader.StartReadingResource()\r\n   at Microsoft.OData.JsonLight.ODataJsonLightReader.ReadResourceSetItemStart(PropertyAndAnnotationCollector propertyAndAnnotationCollector, SelectedPropertiesNode selectedProperties)\r\n   at Microsoft.OData.JsonLight.ODataJsonLightReader.ReadAtStartImplementationSynchronously(PropertyAndAnnotationCollector propertyAndAnnotationCollector)\r\n   at Microsoft.OData.ODataReaderCore.ReadImplementation()\r\n   at Microsoft.OData.ODataReaderCore.InterceptException[T](Func`1 action)\r\n   at System.Web.OData.Formatter.Deserialization.ODataReaderExtensions.ReadResourceOrResourceSet(ODataReader reader)\r\n   at System.Web.OData.Formatter.Deserialization.ODataResourceDeserializer.Read(ODataMessageReader messageReader, Type type, ODataDeserializerContext readContext)\r\n   at System.Web.OData.Formatter.ODataMediaTypeFormatter.ReadFromStream(Type type, Stream readStream, HttpContent content, IFormatterLogger formatterLogger)."
}

Any one Knows how looks the Url to create a record in Dynamics?

Note: Description of the entity ac_sejour: URL:

{{ressource}}/api/data/v9.2/entities?$filter=startswith(name,'ac_sejour')

Postman response:

"value": [
    {
        "entitysetname": "ac_sejours",
        "logicalname": "ac_sejour",
        "logicalcollectionname": "ac_sejours",
        "entityid": "ab71bc28-0486-e911-a827-000d3a2aa91d",
        "reportviewname": "Filteredac_sejour",
        "basetablename": "ac_sejourBase",
        "overwritetime": "1900-01-01T00:00:00Z",
        "versionnumber": 382008802,
        "originallocalizedcollectionname": "Séjours",
        "name": "ac_sejour",
        "componentstate": 0,
        "physicalname": "ac_sejour",
        "collectionname": "ac_sejours",
        "solutionid": "fd140aae-4df4-11dd-bd17-0019b9312238",
        "originallocalizedname": "Séjour",
        "parentcontrollingattributename": null,
        "externalcollectionname": null,
        "extensiontablename": null,
        "externalname": null,
        "addresstablename": null
    }

There is Managed solution/Additional Tool for Dataverse which will give you code snippet with actual values for webapi call. Tool is Dataverse Rest Builder

https://www.xrmtoolbox.com/plugins/GuidoPreite.DRB/

This should give you exact payload with your live data.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM