type 'Null' is not a subtype of type 'int' when using queryParameters
Hi,
I didn't find exactly in the documentation the query params part...
I get error: Error fetching data: type 'Null' is not a subtype of type 'int'
when I do the last query like:
final request = RetrievePageRequest(
id: 579,
queryParameters: {
'acf_format': 'standard',
'_fields': 'acf',
},
);
it's a problem with "_fields"...i've tested in postman an there it works.
Hi @mihaiicey , apologies for the late reply.
I believe this issue occurs because some of the fields in the response model we have currently is not nullable. for example, the id field.
To overcome this, we have a raw request system in the library. Every operation (list, retrieve, get, delete etc) has their equivalent raw operation. you can invoke these by adding raw to the end of the method name. (listRaw, retrieveRaw, etc)
This will skip the model parsing on the library and give the full raw response from the API. Your updated code will be:
final result = await client.pages.retrieveRaw(
RetrievePageRequest(
id: 579,
queryParameters: {
'acf_format': 'standard',
'_fields': 'acf',
},
),
);
final acf = result["acf"];
or to get the acf object safely (no exceptions, nullable, with optional transforming), use result.getField(...)
And yes, the result object is of type WordpressRawResponse it contains all the details you need about the response from the server.
Let me know if you need further help on this.
Read more on this here.