Error with Web Component: toYailDictionary Runtime Error

Hello,
I am currently building a simple translator app and I'm trying to integrate the Google Translate API (v3). However, i keep encountering the following runtime error:
"Runtime Error: unable to invoke method 'toYailDictionary' in object od type string"

Steps i've taken:

  1. i set up the web component and configured the URL
  2. added authorization in the headers using Bearer Token
  3. i structured the body of the POST request with a dictionary

Issue: Even though i pass a dictionary as the body, the app on my Iphone shows the above runtime error.

What is my mistake? Are there any specific limitations wth the Web Component that i should be aware of?

Thank you for your help!!!

Several things:

You did not check response code correctly

You failed to JSON Decode the response content brfore feeding it to a dictionary block.

iOS dictionary pair support is greyed out at
https://doesappinventorrunonios.com/
(though it might not apply to your code)
image

1 Like

What version number do you see in the companion? That function should be in the current App Store version 2.64.5.

The version in the app is 2.64.5 (build 1)

Ok. So I've looked at the code and I think I understand the code path that is failing. It looks like this bug would happen in both the Android and iOS versions. The problem is that the get value at key path block expects either a dictionary or a list of key-value pairs. Since you're passing in the responseContent directly without first parsing it into a dictionary, this fails. toYailDictionary is being called without first checking that the value has that method (not all items would/could) so it blows up there. As @ABG mentioned, you will need to add a call Web1.JsonTextDecodeWithDictionaries to first parse the content.

1 Like

Thank you very much now it is working

I've come up with a fix for this on the iOS side, which should go out in the next iOS release. I'll need to implement the Android version, so I expect that's two release out (early next year).