<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Offline Map Sync Error: Job error 6004 \&amp;quot;invalid start of json - expecting { or [\&amp;quot;. &amp;lt; : 0.&amp;quot; in .NET Maps SDK Questions</title>
    <link>https://community.esri.com/t5/net-maps-sdk-questions/offline-map-sync-error-job-error-6004-quot-invalid/m-p/1146460#M10776</link>
    <description>&lt;P&gt;I am getting same error in fieldmaps android version 22.0.1 Build 1050.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anybody suggest is there any limitation of number of layers or the area?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/3014"&gt;@MichaelBranscomb&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
    <pubDate>Tue, 22 Feb 2022 14:12:56 GMT</pubDate>
    <dc:creator>imritanshu</dc:creator>
    <dc:date>2022-02-22T14:12:56Z</dc:date>
    <item>
      <title>Offline Map Sync Error: Job error 6004 \"invalid start of json - expecting { or [\". &lt; : 0."</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/offline-map-sync-error-job-error-6004-quot-invalid/m-p/1003091#M9578</link>
      <description>&lt;P&gt;I get this error on a regular basis when syncing an offline map.&amp;nbsp; I have noticed it seems to occur when I sync soon after opening a map, and before I have loaded the map into a MapView.&amp;nbsp; I do check to confirm the map and all layers have a LoadStatus = Loaded.&lt;/P&gt;&lt;LI-CODE lang="javascript"&gt;{
	"isServerMessage": false,
	"message": "Layer result: Sync failed. Name: LayerName LayerID: 9 TableName: ... URL: https://services3.arcgis.com/..../arcgis/rest/services/..../FeatureServer/9 Job error 6004 \"invalid start of json - expecting { or [\". &amp;lt; : 0.",
	"severity": "warning",
	"timestamp": 1605810526949
}&lt;/LI-CODE&gt;&lt;P&gt;The was this post a couple years ago:&amp;nbsp;&lt;A href="https://community.esri.com/t5/arcgis-runtime-sdk-for-android/quot-invalid-start-of-json-expecting-or-quot-when-updating-100-1/td-p/690089" target="_blank"&gt;https://community.esri.com/t5/arcgis-runtime-sdk-for-android/quot-invalid-start-of-json-expecting-or-quot-when-updating-100-1/td-p/690089&lt;/A&gt;&lt;/P&gt;&lt;P&gt;But no resolution ever presented&lt;/P&gt;</description>
      <pubDate>Thu, 19 Nov 2020 19:02:32 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/offline-map-sync-error-job-error-6004-quot-invalid/m-p/1003091#M9578</guid>
      <dc:creator>JoeHershman</dc:creator>
      <dc:date>2020-11-19T19:02:32Z</dc:date>
    </item>
    <item>
      <title>Re: Offline Map Sync Error: Job error 6004 \"invalid start of json - expecting { or [\". &lt; : 0."</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/offline-map-sync-error-job-error-6004-quot-invalid/m-p/1004749#M9588</link>
      <description>&lt;P&gt;Anything?&amp;nbsp; This is to where it seems to happen the first time we sync the map no matter what&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/3014"&gt;@MichaelBranscomb&lt;/a&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;&lt;P&gt;&lt;SPAN&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/1052"&gt;@dotMorten_esri&lt;/a&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2020 18:41:23 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/offline-map-sync-error-job-error-6004-quot-invalid/m-p/1004749#M9588</guid>
      <dc:creator>JoeHershman</dc:creator>
      <dc:date>2020-11-25T18:41:23Z</dc:date>
    </item>
    <item>
      <title>Re: Offline Map Sync Error: Job error 6004 \"invalid start of json - expecting { or [\". &lt; : 0."</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/offline-map-sync-error-job-error-6004-quot-invalid/m-p/1004757#M9589</link>
      <description>&lt;P&gt;Hi Joe,&lt;/P&gt;&lt;P&gt;Without a repro it's difficult to tell, but it appears to be returning something other than the expected JSON response, perhaps HTML. Could it be authentication-related? (although a challenge should trigger the registered Authentication Manager challenge)&lt;BR /&gt;&lt;BR /&gt;You could (for debugging purposes only), add an event handler for the response end event and log the responses.&lt;/P&gt;&lt;P&gt;e.g.&lt;/P&gt;&lt;P&gt;Register handler:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;ArcGISHttpClientHandler.HttpResponseEnd += OnHttpResponseEnd;&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Event handler:&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private async void OnHttpResponseEnd(object sender, HttpResponseEndEventArgs e)
{
    using (e.GetDeferral())
    {
        // Await the original response
        var oldContent = e.Response.Content;
        var bytes = await oldContent.ReadAsByteArrayAsync().ConfigureAwait(false);
                
        // Get the response string
        string responseString = Encoding.ASCII.GetString(bytes);
        // TODO : Log the response
        // e.g. Use a TextWriterTraceListener and call Trace.TraceInformation(responseString);

        // Wrap it in a new ByteArrayContent so it can be consumed again
        var newContent = new ByteArrayContent(bytes);
        foreach (var header in oldContent.Headers)
            newContent.Headers.TryAddWithoutValidation(header.Key, header.Value);
        e.Response.Content = newContent;
    }
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Thanks&lt;/P&gt;&lt;P&gt;Mike&lt;/P&gt;</description>
      <pubDate>Wed, 25 Nov 2020 18:51:14 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/offline-map-sync-error-job-error-6004-quot-invalid/m-p/1004757#M9589</guid>
      <dc:creator>MichaelBranscomb</dc:creator>
      <dc:date>2020-11-25T18:51:14Z</dc:date>
    </item>
    <item>
      <title>Re: Offline Map Sync Error: Job error 6004 \"invalid start of json - expecting { or [\". &lt; : 0."</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/offline-map-sync-error-job-error-6004-quot-invalid/m-p/1005605#M9596</link>
      <description>&lt;P&gt;Mike,&lt;/P&gt;&lt;P&gt;I put the handler in place - required I upgrade the Runtime as it was not there in 100.6.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;The log includes a "OnHttpResponseEnd" line before any log entry from there to differentiate from other locations.&amp;nbsp; I also log other pertinent aspects of the process.&amp;nbsp;&lt;/P&gt;&lt;P&gt;Primary aspects of the log that relate to the timing of the HttpResponse messages&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;_log.Debug("STARTING SYNC");
var results = await job.GetResultAsync();
_log.Debug("SYNC COMPLETE");&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;I also log to show when the ChallengeHandler is requested&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;public async Task&amp;lt;Credential&amp;gt; CreateCredentialAsync(CredentialRequestInfo info)
{
	try
	{
		_log.Info($"CHALLENGE  ********** : {info.ServiceUri} ***********");
		if ( info.ServiceUri == null ) return null;

		var credential = await AuthenticationManager.Current.GenerateCredentialAsync(info.ServiceUri, Settings.UserName, Settings.Password);

		_log.Info($"RETURN credential *********: {info.ServiceUri} ********");
		return credential;
	}
	catch (Exception e)
	{
		_log.Error(e, e.Message);

		return null;
	}
}&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;It seems the call is made to GetResultAsync which then does not have any token, so it calls into the ChallngeHandler to get a token.&amp;nbsp; What seems to be happening, though is the Sync request is still processing while the Challenge is also occurring.&amp;nbsp; So, the sync is trying to process without actually waiting for the token to be returned.&amp;nbsp; Then you get some bizarre returning of all the html copies of the sync request pages (which I assume is where our json errors come from).&lt;/P&gt;&lt;P&gt;Then I go into a sync again and it all works, I assume because the previous request for a token is complete.&amp;nbsp; I had previously tried some other things to using a ChallengeHandler which had similar results but I don't have logging for right now.&lt;/P&gt;&lt;P&gt;Prior to making the sync call instead of using a ChallengeHandler I simply added the credential&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;AuthenticationManager.Current.AddCredential(await _portalManager.Credential(true));&lt;/LI-CODE&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Also I had things setup that the user connects to AGOL when they first log into the application, this way I can test that the user entered credentials are valid when the user first opens the application instead of waiting until they are doing something requiring a connection (sync or downloading an offline map).&lt;/P&gt;&lt;P&gt;If my assumption is correct how can I process the Credential requests and be sure they are 100% complete prior to attempting the sync?&lt;/P&gt;&lt;P&gt;I will email you he log file because the new GeoNet does not seem to want to allow me to upload&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2020 19:31:19 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/offline-map-sync-error-job-error-6004-quot-invalid/m-p/1005605#M9596</guid>
      <dc:creator>JoeHershman</dc:creator>
      <dc:date>2020-11-30T19:31:19Z</dc:date>
    </item>
    <item>
      <title>Re: Offline Map Sync Error: Job error 6004 \"invalid start of json - expecting { or [\". &lt; : 0."</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/offline-map-sync-error-job-error-6004-quot-invalid/m-p/1005624#M9597</link>
      <description>&lt;P&gt;So I tried this with the change that I first log onto AGOL prior to the sync, in that case I see similar results except it never actually goes into the ChallengeHandler.&amp;nbsp; I was thinking maybe it has to do with the WebMap, but I tried with another WebMap and seems to still have the issue.&amp;nbsp; I am having a hard time with no one being able to duplicate with this happening every single time I try a first sync.&amp;nbsp; I am willing to share the code, privately, if someone is willing to do that.&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Mon, 30 Nov 2020 19:29:48 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/offline-map-sync-error-job-error-6004-quot-invalid/m-p/1005624#M9597</guid>
      <dc:creator>JoeHershman</dc:creator>
      <dc:date>2020-11-30T19:29:48Z</dc:date>
    </item>
    <item>
      <title>Re: Offline Map Sync Error: Job error 6004 \"invalid start of json - expecting { or [\". &lt; : 0."</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/offline-map-sync-error-job-error-6004-quot-invalid/m-p/1005668#M9598</link>
      <description>&lt;P&gt;I added this to occur in my processing which seems to resolve the issue, not really excited about it as a workaround, but for now will have to do&lt;/P&gt;&lt;LI-CODE lang="csharp"&gt;private bool _firstSync = true;

private async Task InitialzeTokens()
{
	if ( !_firstSync ) return;

	foreach (var featureLayer in _map.OperationalLayers.OfType&amp;lt;FeatureLayer&amp;gt;())
	{
		var pars = new QueryParameters {WhereClause = "1=0", MaxFeatures = 1};

		if ( !(featureLayer.FeatureTable is GeodatabaseFeatureTable gdbFeatureTable) ) continue;
		if ( gdbFeatureTable.Geodatabase?.Source == null ) continue;

		var serviceFeatureTable = new ServiceFeatureTable(gdbFeatureTable.Geodatabase.Source);

		try
		{
			await serviceFeatureTable.LoadAsync();
			var _ = await serviceFeatureTable.QueryFeaturesAsync(pars);
		}
		catch (Exception)
		{
			//_log.Error(e, e.Message);
		}
	}

	_firstSync = false;
}&lt;/LI-CODE&gt;</description>
      <pubDate>Mon, 30 Nov 2020 21:29:33 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/offline-map-sync-error-job-error-6004-quot-invalid/m-p/1005668#M9598</guid>
      <dc:creator>JoeHershman</dc:creator>
      <dc:date>2020-11-30T21:29:33Z</dc:date>
    </item>
    <item>
      <title>Re: Offline Map Sync Error: Job error 6004 \"invalid start of json - expecting { or [\". &lt; : 0."</title>
      <link>https://community.esri.com/t5/net-maps-sdk-questions/offline-map-sync-error-job-error-6004-quot-invalid/m-p/1146460#M10776</link>
      <description>&lt;P&gt;I am getting same error in fieldmaps android version 22.0.1 Build 1050.&amp;nbsp;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Can anybody suggest is there any limitation of number of layers or the area?&amp;nbsp;&lt;/P&gt;&lt;P&gt;&lt;a href="https://community.esri.com/t5/user/viewprofilepage/user-id/3014"&gt;@MichaelBranscomb&lt;/a&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Tue, 22 Feb 2022 14:12:56 GMT</pubDate>
      <guid>https://community.esri.com/t5/net-maps-sdk-questions/offline-map-sync-error-job-error-6004-quot-invalid/m-p/1146460#M10776</guid>
      <dc:creator>imritanshu</dc:creator>
      <dc:date>2022-02-22T14:12:56Z</dc:date>
    </item>
  </channel>
</rss>

