Error while consuming the deployed web service through python

Senthil Murugan RAMACHANDRAN 21 Reputation points

I have tried consuming the web service with python with the link how-to-consume-web-service. I'm getting an error

predict() missing 1 required positional argument: 'X'

I have trained the model to predict only one field " DESCRIPTION" and two input fields "CUSTOMERCODE", "DESCRIPTION"

when I try to predict with input data with the code below:

import requests
import json

URL for the web service

scoring_uri = 'xxx'

If the service is authenticated, set the key or token

key = 'xxx'

Two sets of data to score, so we get two results back

data = {"data":
input_data = json.dumps(data)
headers = {'Content-Type': 'application/json'}
headers['Authorization'] = f'Bearer {key}'
resp =, input_data, headers=headers)

Azure Machine Learning
Azure Machine Learning
An Azure machine learning service for building and deploying models.
2,653 questions
{count} votes

2 answers

Sort by: Most helpful
  1. GiftA-MSFT 11,161 Reputation points

    It seems your input is CUSTOMERCODE and target is DESCRIPTION, however, you are entering data for the target column when it is expecting only CUSTOMERCODE as input. Hope this helps!

  2. GiftA-MSFT 11,161 Reputation points

    Hi, can you try testing your model locally first to view the results and the expected format for your test data? It seems you performed some transformations when fitting the model, so you need to ensure that you are providing your test data with the expected shape and dimension of the array. Hope this helps!

    0 comments No comments