Missing attributes single asset on Block

My schema looks like that :

Block: key_point who has two fields title (Single-line string) and image (Single asset)
Model: runtime who has two fields slug and key_points (Modular content) that only accept one type of Block (key_point)

client = Dato::Site::Client.new(ENV["DATO_API_TOKEN_RW"])

runtime = client.items.all(
  nested: true,
  filter: {
    type: "runtime",
    fields: {
      slug: {eq: "my-slug"},
    },
  },
).first

key_points = runtime["key_points"]
puts key_points["en"].first
# {"id"=>"10622761", "type"=>"item", "attributes"=>{"title"=>"Toto"}, "relationships"=>{"item_type"=>{"data"=>{"id"=>"401631", "type"=>"item_type"}}}}

key_point_id = key_points["en"].first["id"]
key_point = client.items.find(key_point_id, nested: "true")
puts key_point
# {"id"=>"10622761",
#  "meta"=>
#   {"created_at"=>"2020-11-14T17:48:25.141+01:00",
#    "updated_at"=>"2020-11-14T17:48:25.144+01:00",
#    "published_at"=>"2020-11-14T17:48:25.880+01:00",
#    "publication_scheduled_at"=>nil,
#    "unpublishing_scheduled_at"=>nil,
#    "first_published_at"=>"2020-11-14T17:48:25.880+01:00",
#    "is_valid"=>true,
#    "status"=>"published",
#    "current_version"=>"21006016",
#    "stage"=>nil},
#  "title"=>"Toto",
#  "updated_at"=>"2020-11-14T17:48:25.144+01:00",
#  "created_at"=>"2020-11-14T17:48:25.141+01:00",
#  "item_type"=>"401631"}

I don’t have any reference to my image field, is it a bug ? Should I do something differently?

Thanks for the help
Jean

hey @jean could it be that the image is not a required field in your block and so it has not been filled by your editors?

Also the nested: "true" should be done on the parent record and it will get you the record and the content of the blocks in one call. Makes sense?

I just checked and it’s filled

Also the nested: "true" should be done on the parent record and it will get you the record and the content of the blocks in one call. Makes sense?

That’s what I did, no ?

You should run the nested: "true" on the runtime that has the nested key_points to get all in one go.

Still the image should be there :slight_smile:

Are you using the latest version of the client? Can you please share the full code example (with API token) via email at support@datocms.com so that I can try running it myself and see how it goes?

I was not setting the environment …

client = Dato::Site::Client.new(ENV["DATO_API_TOKEN_RW"], environment: "next")

Now it’s working as expected, thanks !

PS: the support doesn’t need the API token they found my project with my email :slight_smile: