Developer forum

Forum » Integration » "Given Key" Error and Missing Mapped Fields in Response (OdataProvider/Platform)

"Given Key" Error and Missing Mapped Fields in Response (OdataProvider/Platform)

Kyle Fesmire
Reply

Hi team,

Getting an error that I think is either OdataProvider or platform related. We have a job for importing customers that is failing with the following error:

Job Failed with the following message: The given key was not present in the dictionary. The failed input row is: [@odata.etag:"W/"JzIwOzE3NTgwNjc2NTkyNjc0NDMyNzA2MTswMDsn""], [AccessUserExternalId:"L05338"], [AccessUserCustomerNumber:"L05338"], [AccessUserUserName:"Customer_L05338"], [AccessUserName:""], [AccessUserEmail:""], [AccessUserPhone:""], [AccessUserAddress:""], [AccessUserAddress2:""], [AccessUserZip:""], [AccessUserCity:""], [AccessUserState:""], [AccessUserActive:"True"], [AccessUserWeb:""], [AccessUser_SalesRepId:""], [AccessUserGroups:"All Customers,Law Enforcement"], [AccessUser_BlockedAccount:"False"], [AccessUserTaxAreaCode:"AVATAX"], [AccessUser_CreditLimit:"0.00"], [AccessUser_TaxLiable:"True"]. System.Collections.Generic.KeyNotFoundException: The given key was not present in the dictionary. at System.ThrowHelper.ThrowKeyNotFoundException() at System.Collections.Generic.Dictionary`2.get_Item(TKey key) at Dynamicweb.DataIntegration.Providers.UserProvider.UserDestinationWriter.Write(Dictionary`2 row, Mapping mapping, Boolean discardDuplicates) at Dynamicweb.DataIntegration.Providers.UserProvider.UserProvider.RunJob(Job job)

This error indicates that the source and destination do not match when running the import job. I've tried to refresh the schema, but that doesn't change the behavior at all. Also, the job runs a few pages of data before it fails - which if this was truly a source/destination schema mismatch, it should fail on the first attempt or page. 

I think what is happening here is that the response is being cut off in DW, and it is leaving off about 4 fields that are mapped in DW and should be importing. If you look at the error message above, the response stops at AccessUser_TaxLiable:"True", but if we look at the request in postman with the select statement, you see that there are 4 more fields there it should be grabbing. It's odd that the job can run for a little while before encountering this error, but that is also what makes me think it is related to the provider or some other platform issue. 

Request with Select Statement:

https://api.businesscentral.dynamics.com/v2.0/562d2080-17d4-47c5-9a80-bf25fe13e017/Production/api/Dynamicweb/Dynamicweb/V2.0/companies(ce4c5d6c-2378-ee11-817a-000d3a043b29)/dwCustomers?$select=AccessUserExternalId%2CAccessUserCustomerNumber%2CAccessUserUserName%2CAccessUserName%2CAccessUserEmail%2CAccessUserPhone%2CAccessUserAddress%2CAccessUserAddress2%2CAccessUserZip%2CAccessUserCity%2CAccessUserState%2CAccessUserActive%2CAccessUserWeb%2CAccessUser_SalesRepId%2CAccessUser_BlockedAccount%2CAccessUserTaxAreaCode%2CAccessUser_CreditLimit%2CAccessUser_TaxLiable%2CLawEnforcementGovernmentAgency%2CAccessUser_CanPayOnAccount%2CFFLNo%2CFFLExpirationDate%2CAccessUserGroups%2CFFLExpirationDate

Response with fields that are missing from the errror message:

        {
            "@odata.etag": "W/\"JzIwOzE3NTgwNjc2NTkyNjc0NDMyNzA2MTswMDsn\"",
            "AccessUserExternalId": "L05338",
            "AccessUserCustomerNumber": "L05338",
            "AccessUserUserName": "Customer_L05338",
            "AccessUserName": "",
            "AccessUserEmail": "",
            "AccessUserPhone": "",
            "AccessUserAddress": "",
            "AccessUserAddress2": "",
            "AccessUserZip": "",
            "AccessUserCity": "",
            "AccessUserState": "",
            "AccessUserActive": true,
            "AccessUserWeb": "",
            "AccessUser_SalesRepId": "",
            "AccessUserGroups": "All Customers,Law Enforcement",
            "AccessUser_BlockedAccount": false,
            "AccessUserTaxAreaCode": "AVATAX",
            "AccessUser_CreditLimit": "0.00",
            "AccessUser_TaxLiable": true,
            "FFLNo": "",
            "FFLExpirationDate": "01/01/1970",
            "LawEnforcementGovernmentAgency": "Law Enf./Govt. Agcy FET Exempt",
            "AccessUser_CanPayOnAccount": true

        },

We have tried moving the job to delta replication, lowering request/page sizes, and updating the odata provider - no luck yet. 

OdataProvider version was updated from 3.0.8 to 3.0.10 but still experiencing the same behavior. Please advise.

Thanks!
KF


Replies

 
Matthias Sebastian Sort Dynamicweb Employee
Matthias Sebastian Sort
Reply

Hi Kyle,
 
Schemas is only used to show table and column mapping in the UI.
 
It's a little bit hard to investigate the issue, but something tells me that it is the User Provider (Destination) who has the issue.

You can try and move your column mappings of "FFLNo", "FFLExpirationDate", "LawEnforcementGovernmentAgency", "AccessUser_CanPayOnAccount" above the "AccessUser_TaxLiable" to see if that helps? Otherwise you will need to go through our Care department so we can get all the info to do a proper investigation. 
 
BR
Matthias Sort

 
Kyle Fesmire
Reply

Thanks for your response Matthias! 

I have reached out to the Care team and will try moving around the mappings to see if that helps.

Thanks!
KF

 

You must be logged in to post in the forum