Your problem is your data is returning arrays in places. Try the following:
data = [
{
"ID": "295699",
"restriction": [
{
"restrictionTypeCode": "10001"
}
]
}
]
data.first[:restriction].first[:restrictionTypeCode]
# to make this safe from any nil values you may encounter, you might want to use
data.first&.dig(:restriction)&.first&.dig(:restrictionTypeCode)
# => "10001"
# or
data.flat_map { |hsh| hsh[:restriction]&.map { |sub_hsh| sub_hsh[:restrictionTypeCode] } }
# => ["10001"]
To break it down a little, your top level response and that falling under the key :restriction both return arrays; therefore, to get the data from them you either need to access one of the items they contain (in my example using first) or map them (the second example).
I've added some checks for nil values in there: this is pretty vital when dealing with API responses as you're not in control of the data so can't be certain all the fields will be present. Rather than throw an error should you encounter data like this, you'll get nil returned to avoid breaking subsequent code.
Hope this helps - let me know how you get on or if you have any questions :)