betodealmeida / shillelagh

Making it easy to query APIs via SQL

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

shillelagh error: 'str' object has no attribute 'items' in superset

weeebdev opened this issue · comments

Describe the bug
When I try to connect to json api like https://www.boredapi.com/api/activity?participants=1,
it returns me "shillelagh error: 'str' object has no attribute 'items'"

To Reproduce
Steps to reproduce the behavior:

  1. Install superset with shillelagh
  2. Try to do an api request

Expected behavior
Normal api response

Screenshots
image

Desktop (please complete the following information):

  • OS: Mac (Docker Actually)
  • Browser [Arc]

Additional context
Here is my config in superset:

{
  "connect_args": {
    "adapters": [
      "genericxmlapi",
      "genericjsonapi",
      "datasetteapi",
      "weatherapi"
    ],
    "adapter_kwargs": {
      "weatherapi": { "api_key": "API_KEY" },
      "genericjsonapi": {
        "request_headers": {
          "Content-type": "application/json"
        }
     }
    
}

Well, it seems that the request is being executed. Something is happening at the response processing.
image

Taking a look, thanks for the report!

Taking a look, thanks for the report!

Thanks a lot! I'll be very glad if you could keep me up to date about this bug. Really important to me now.

@weeebdev I have a fix here: #431

Note that you'll have to specify a different JSONPath to get it to work, since the API returns a single dictionary as the response. You'll need to use this URI: "https://www.boredapi.com/api/activity?participants=1#$"

I'll release a new version as soon as the PR is merged.

This is now fixed in 1.2.16.

@betodealmeida btw, it turned out that I faced another bug when I tried to use rest api provided by https://github.com/hapifhir/hapi-fhir
Apparently, it returns Content-Type:application/fhir+json;charset=UTF-8 while in the code it directly checks

return cls.content_type in response.headers.get("content-type", "") #72 line

Therefore, I made a quick fix via regex pattern. mylifestats@eb8eada

Please, consider fixing it.