Skip to content

Problems with GetDocumentFile #1

@towebo

Description

@towebo

Hi!
I tried to download the PDF by calling GetDocumentFile but there was no suitable class to pass. The call returns the file contents as a string so I had to update the ApiResponse.GetResponse<() call with the following addition:

string responseBody = await response.Content.ReadAsStringAsync();

        // 2020-12-29 Necessary to get the PDF data
        if (typeof(TResult) == typeof(string))
        {
            return (TResult)Convert.ChangeType(responseBody, typeof(TResult));
            
        }

            return JsonConvert.DeserializeObject<TResult>(responseBody);

Now I'm able to get the PDF with the following:

string str_data = await vsign.SendRequest(
GetDocumentFile.FromDocument(loc.Uuid, 0)
);
byte[] data = Encoding.UTF8.GetBytes(str_data);
File.WriteAllBytes(

One could absolutely create a specific class to handle this like the LocationDto but this is good enough and it's flexible because you can always get the raw string response from the call.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions