# Trouble with the built in inference API example

**URL:** <https://discuss.huggingface.co/t/trouble-with-the-built-in-inference-api-example/6983>\
**Category:** Beginners\
**Created:** [June 18, 2021, 8:23pm UTC](https://discuss.huggingface.co/t/trouble-with-the-built-in-inference-api-example/6983 "2021-06-18T20:23:05Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![LowellR](https://avatars.discourse-cdn.com/v4/letter/l/7bcc69/32.png) [@LowellR](https://discuss.huggingface.co/u/LowellR)\
**Post date:** [June 18, 2021, 8:23pm UTC](https://discuss.huggingface.co/t/trouble-with-the-built-in-inference-api-example/6983/1 "2021-06-18T20:23:05Z")

</div>

Hi I’m just starting out with the inference API examples. While I can get other examples to work using the same formatting , I get this error

{“error”:“d argument needs to be of type (SquadExample, dict)”}

When using the example for [deepset/roberta-base-squad2 · Hugging Face](https://huggingface.co/deepset/roberta-base-squad2)

```auto
import json
import requests

API_URL = "https://api-inference.huggingface.co/models/deepset/roberta-base-squad2"
headers = {"Authorization": "Bearer api_xxx"}

def query(payload):
	data = json.dumps(payload)
	response = requests.request("POST", API_URL, headers=headers, data=data)
	return json.loads(response.content.decode("utf-8"))

data = query(
    {
        "inputs": {
            "question": "What's my name?",
            "context": "My name is Clara and I live in Berkeley.",
        }
    }
)

```

I’d love know how else to format the query, or what else I should double check.

Thanks for reading.

---

<div class="post-metadata">

**Author:** ![osanseviero](https://sea2.discourse-cdn.com/hellohellohello/user_avatar/discuss.huggingface.co/osanseviero/32/38738_2.png) [@osanseviero](https://discuss.huggingface.co/u/osanseviero)\
**Post date:** [June 19, 2021, 1:51pm UTC](https://discuss.huggingface.co/t/trouble-with-the-built-in-inference-api-example/6983/2 "2021-06-19T13:51:07Z")

</div>

Hi @LowellR

I just tried your exact pasted code and it worked fine.

`{'answer': 'Clara', 'end': 16, 'score': 0.9326569437980652, 'start': 11}`

Could you confirm if you are running this same code?  
Thanks!

---

<div class="post-metadata">

**Author:** ![LowellR](https://avatars.discourse-cdn.com/v4/letter/l/7bcc69/32.png) [@LowellR](https://discuss.huggingface.co/u/LowellR)\
**Post date:** [June 19, 2021, 6:40pm UTC](https://discuss.huggingface.co/t/trouble-with-the-built-in-inference-api-example/6983/3 "2021-06-19T18:40:26Z")

</div>

Thanks for taking a look @osanseviero I appreciate you testing it out. I must have some sort of formatting issue. I’ll take another look.
