cancel
Showing results for 
Search instead for 
Did you mean: 
Reply
Highlighted
New Member

HTTP Request to Azure Machine Learning Web Services

Hi all,

 

I would like to use Flow to call a web service but I am getting the error:

No request body provided or error in deserializing the request body.

Background: 

I have trained classifier using Azure Machine Learning Studio and am able to call it in Python through a web request. The code for this is below. However I would like to be able to call this web request using Flow. I cannot seem to get it right.

 

Python:

import urllib.request
import json

data = {
        "Inputs": {
                "input1":
                [
                    {
                            'Subject_Tag_00': "delete",   
                            'Subject_Tag_01': "recycle",   
                            'Subject_Tag_02': "bin",   
                            'Body_Tag_00': "N/A",   
                            'Body_Tag_01': "N/A",   
                            'Body_Tag_02': "N/A",   
                            'Body_Tag_03': "N/A",   
                            'Body_Tag_04': "N/A",   
                            'Answer': "",   
                    }
                ],
        },
    "GlobalParameters":  {
    }
}

body = str.encode(json.dumps(data))


url = 'Uri from the second image in this post'
api_key = 'Primary Key from the second image in this post' 
headers = {'Content-Type':'application/json', 'Authorization':('Bearer '+ api_key)}

req = urllib.request.Request(url, body, headers)

try:
    response = urllib.request.urlopen(req)

    result = response.read()
    print(result)
except urllib.error.HTTPError as error:
    print("The request failed with status code: " + str(error.code))

    # Print the headers - they include the requert ID and the timestamp, which are useful for debugging the failure
    print(error.info())
    print(json.loads(error.read().decode("utf8", 'ignore')))

 

This is the error I receive when making the request through Flow is:

{
  "error": {
    "code": "BadArgument",
    "message": "Invalid argument provided.",
    "details": [
      {
        "code": "RequestBodyInvalid",
        "message": "No request body provided or error in deserializing the request body."
      }
    ]
  }
}

I have tried a number of different formats for the body of the request. Below isa picture of one of them.

Flow_01

 

I am getting my info from this page.

 

I think the error is about how I am formatting the body of the request but I am not sure.  Does anyone have any insight into this?

 

Thank you,

Clint

 

 

1 REPLY 1
Highlighted
Super User II
Super User II

Hi @ClintonWalsh 

I just stumbled on your request. You've been waiting a while for a reply.

Were you able to solve it? Can you post the solution so that we can all learn from it?

If you still need help, please let me know what changed.

If I have answered your question, please mark your post as Solved.
If you like my response, please give it a Thumbs Up.

Cheers
Manuel

Helpful resources

Announcements
Community Conference

Power Platform Community Conference

Check out the on demand sessions that are available now!

Power Platform ISV Studio

Power Platform ISV Studio

ISV Studio is designed to become the go-to Power Platform destination for ISV’s to monitor & manage published applications.

Users online (13,960)