I need a little help extracting data from Microsoft CRM365 using REST API. I can only read 5000 rows at a time, then have it return me the next URL in a variable. Here is the script I am using along with the error. Thanks.
LET vURL = 'https://xxxxxqas.api.crm.dynamics.com/api/data/v9.0/accounts'; LET i = 1; DOwhile LEN(vURL) > 0 CUSTOM CONNECT TO "Provider=QvRestConnector.exe;url=$(vURL);timeout=30;method=GET;sendExpect100Continue=True;autoDetectResponseType=true;checkResponseTypeOnTestConnection=true;keyGenerationStrategy=0;authSchema=anonymous;skipServerCertificateValidation=false;useCertificate=No;certificateStoreLocation=CurrentUser;certificateStorbeeName=My;queryHeaders=OData-MaxVersion%24.0%1OData-Version%24.0%1Authorization%2Bearer $(vToken);PaginationType=None;allowResponseHeaders=false;allowHttpsOnly=false;XUserId=ZCASARB;XPassword=GbTdcBA;";
RestConnectorMasterTable: SQL SELECT "@odata.context", "@odata.nextLink", "__KEY_root", (SELECT "@odata.etag", "accountid", "__FK_value" FROM "value" FK "__FK_value") FROM JSON (wrap on) "root" PK "__KEY_root";
[Accounts]: LOAD [@odata.etag], [accountid], [__FK_value] AS [__KEY_root] RESIDENT RestConnectorMasterTable WHERE NOT IsNull([__FK_value]); STORE * FROM [RestConnectorMasterTable] into qvd\Accounts365.QVD ; [root]: LOAD [@odata.context], [__KEY_root] RESIDENT RestConnectorMasterTable WHERE NOT IsNull([__KEY_root]); Let vURL = FieldValue('@odata.nextLink',1); LET i=i+1; Loop DROP TABLE RestConnectorMasterTable; ExitSCRIPT;
Here is the error I get:
QVX_UNEXPECTED_END_OF_DATA: HTTP protocol error 500 (Internal Server Error):
{"error":{"code":"0x80040216","message":"Malformed XML","innererror":{"message":"Malformed XML","type":"Microsoft.Crm.CrmException","stacktrace":" at Microsoft.Crm.Extensibility.OData.CrmODataUtilities.DeserializePagingCookie(String batchCookie)\r\n at Microsoft.Crm.Extensibility.OData.CrmODataU... RestConnectorMasterTable: SQL SELECT "@odata.context", "@odata.nextLink", "__KEY_root", (SELECT "@odata.etag", "accountid", "__FK_value" FROM "value" FK "__FK_value") FROM JSON (wrap on) "root" PK "__KEY_root"