Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

properly flush the file bytes #9

Merged
merged 1 commit into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 11 additions & 4 deletions Socrata/DSMAPI/Revision/Revision.cs
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,17 @@ public Revision(SocrataHttpClient httpClient, RevisionResponse response)
}
private SourceResponse CreateSource(Dictionary<string, string> source)
{
System.Console.WriteLine(string.Join(Environment.NewLine, source));
Dictionary<string, object> sourceType = new Dictionary<string, object>();
sourceType.Add("source_type", source);
System.Console.WriteLine(string.Join(Environment.NewLine, sourceType));
Console.WriteLine(string.Join(Environment.NewLine, source));
Dictionary<string, object> sourceType = new Dictionary<string, object>
{
{ "source_type", source }
};
Dictionary<string, bool> parseOptions = new Dictionary<string, bool>
{
{ "parse_source", true }
};
sourceType.Add("parse_options", parseOptions);
Console.WriteLine(string.Join(Environment.NewLine, sourceType));
SourceResponse result = HttpClient.PostJson<SourceResponse>(Links.CreateSource, sourceType);
return result;
}
Expand Down
1 change: 1 addition & 0 deletions Socrata/DSMAPI/Source/ByteSink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ public void FileSink(string filepath)
resp = WriteBytes(b);
this.seq_num += 1;
this.byte_offset += b.Length;
b = new byte[this.preferred_chunk_size];
}
}

Expand Down
11 changes: 9 additions & 2 deletions Socrata/Http/SocrataHttpClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,8 +96,15 @@
public T GetJson<T>(string endpoint) where T : class
{
var resp = Get(endpoint);
var result = Newtonsoft.Json.JsonConvert.DeserializeObject<T>(resp.Content.ReadAsStringAsync().Result);
return result;
var s = resp.Content.ReadAsStringAsync().Result;
try {
var result = Newtonsoft.Json.JsonConvert.DeserializeObject<T>(s);
return result;
} catch (Exception e) {

Check warning on line 103 in Socrata/Http/SocrataHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

The variable 'e' is declared but never used

Check warning on line 103 in Socrata/Http/SocrataHttpClient.cs

View workflow job for this annotation

GitHub Actions / build

The variable 'e' is declared but never used
Console.WriteLine(s);
return null;
}

}

public T GetJson<T>(Uri uri) where T : class
Expand Down
2 changes: 1 addition & 1 deletion Socrata/Socrata.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@

<PackageId>Socrata</PackageId>

<Version>2.4.0</Version>
<Version>2.5.0</Version>

<Description>Socrata .NET Client</Description>

Expand Down
Loading