How to query a content by Id and get all localized rich text fields as HTML with .NET client?

I have…

  • Read the following guideline: Troubleshooting and Support | Squidex. I understand that my support request might get deleted if I do not follow the guideline.
  • Used code blocks with ``` to format my code examples like JSON or logs properly.

I’m submitting a…

  • Regression (a behavior that stopped working in a new release)
  • Bug report
  • Performance issue
  • Documentation issue or request

Current behavior

We are currently using the .NET client (latest NuGet version 19.2.0) to get the contents via the IContentsClient.GetAsync(id) endpoint.

Is it possible to receive all rich text fields in the defined content model as HTML?

I saw in this other question that it is possible via the GraphQL API to specify html has return value. As far as I have figured out, it is not possible to query Squidex via GraphQL with the .NET client (please correct me if I’m wrong). Also, querying via GraphQL is inconvinient for localized rich text fields as we would need to query for each single language separately since specifying the html “subfield” in the GraphQL query lies below the language “field”, e.g. when querying languages “en” and “de” we would need the following two GraphQL queries:

{
  queryDocumentsContents(filter:""){
    data{
      content{
        en{
          html
        }
      }
    }
  }
}

and

{
  queryDocumentsContents(filter:""){
    data{
      content{
        de{
          html
        }
      }
    }
  }
}

Expected behavior

Have a way to receive the rich text contents as HTML with the .NET client.

It would be helpful if we could specify the content model as string and receive the HTML for all languages in the localized rich text fields at once. It this possible somehow?

Minimal reproduction of the problem

/

Environment

App Name:

  • Self hosted with docker
  • Self hosted with IIS
  • Self hosted with other version
  • Cloud version

Browser:

  • Chrome (desktop)
  • Chrome (Android)
  • Chrome (iOS)
  • Firefox
  • Safari (desktop)
  • Safari (iOS)
  • IE
  • Edge

Others:

You can make GraphQL queries with the .NET client. E.g. Have a look to the following tests:

Unfortunately you have to define each language manually, I don’t see a way to prevent that.

But you can also make a single query:

{
  queryDocumentsContents(filter:""){
    data{
      content{
        en{
          html
        }
        de{
          html
        }
      }
    }
  }
}
1 Like

Thank you for your response and for the hint that we can make a single query. We can work with that.

We tried to query the list of languages of the app, so that we know which languages to query, but we receive a 403 Forbidden when using the endpoint:

GET https://cloud.squidex.io/api/apps/<appname>/languages

Should this work or are we missing something? We are using a client with role “Reader”.

We also tried to use the https://cloud.squidex.io/api/languages endpoint from the General API, but with that we get all languages (more than 500) and we receive an error when querying our rich text contents because not all languages are available in the app and therefore also not available as GraphQL property.

Yes, the reader just does not have permissions for this endpoint. You have to use another role or you have to create a special role with just the permissions you need.

Got it, thank you. We now created a custom role where we added the permission to read languages.

Thanks for your help. Everything we need is working now.

1 Like