You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
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:
it's a problem with "_fields"...i've tested in postman an there it works.
The text was updated successfully, but these errors were encountered: