Skip to content

Deserialization of 'ShopifySharp.GraphQL.FileCreatePayload' failed. #1258

Description

@samuelcadima

I've been implementing some requests with the fluent GraphQL query builder and I successfully created a file on my store but I'm getting this exception when I deserialize the response:

Inner Exception 1:
ShopifyUnspecifiedTypeDiscriminatorException: Deserialization of 'ShopifySharp.GraphQL.FileCreatePayload' failed. The JSON payload for the GraphQL union or interface type 'ShopifySharp.GraphQL.IFile' at JSON path 'data' does not include the required type discriminator ('__typename'). Add '__typename' to your query selection for this type to enable polymorphic deserialization.

Inner Exception 2:
NotSupportedException: The JSON payload for polymorphic interface or abstract type 'ShopifySharp.GraphQL.IFile' must specify a type discriminator. Path: $.files[0] | LineNumber: 0 | BytePositionInLine: 16.

I found this issue, but the solution is for the previous implementation.

Here is my code:

var files = new List<FileCreateInput>()
{ new FileCreateInput() {
    contentType = FileContentType.IMAGE,
    originalSource = url,
    filename = url.Split('/').Last()
}};

var builder = new FileCreateOperationQueryBuilder().Files(f => f.Id()).UserErrors(u => u.Message().Field()).SetArguments(p => p.Files(files));
var result = Provider.GraphService.PostAsync(GraphRequest.FromQueryBuilder(builder)).Result;

Is there a parameter missing?

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions