Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8108463
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T01:07:00+00:00 2026-06-06T01:07:00+00:00

I’m learning Python and trying to test some rest web_service applications. From the below

  • 0

I’m learning Python and trying to test some rest web_service applications. From the below code what I’m trying to do is to post something and to get the result. When I launch this the console gives me this:

Traceback (most recent call last):
  File "D:\workspaces_branch1\csse120\TestPythonProject\src\UTF-Rest-Client.py", line 9, in <module>
    import restful_lib
ImportError: No module named restful_lib

I think it’s because I don’t have this restful_lib module. where can I get it and how can I install it?
also, I want to know if the launch is good how can I get the returned data?

import argparse

#additional lib, need installation (see README)
import restful_lib

testQueueId = 0

# FUNCTIONS

#generate POST content

def postContent():

        xmlData = "<testQueueRequestByNewnancy>"+ \
        "<nancy>"+ \
        "<nancyTargetId>" + args.nancyTargetID + "</nancyTargetId>"+ \
        "<nancyUrl>" + args.nancyUrl + "</nancyUrl>"+ \
        "<nancyVersion>" + args.nancyVersion + "</nancyVersion>"+ \
        "<projectId>" + args.projectID + "</projectId>"+ \
        "<MumID>" + args.MumID + "</MumID>"+ \
        "</nancy>"+ \
            "<user>"+ \
                "<id>" + args.userID + "</id>"+ \
             "</user>"+ \
         "</testQueueRequestByNewnancy>"   

        printVerbose('xmlData =' + xmlData)
        return xmlData

#this function will print text only if verbose is on

def printVerbose(text):
    if args.verbose:
        print(text)


#this function will instruct scheduler through REST API call to do new tests

def callRestApi(content):
    printVerbose('calling REST scheduler API...')

    #recreate complete URL
    base_url = 'http://localhost:8080/test'
    #ensure http:// is at the beginning
    if (base_url[0:7].lower() != 'http://'):
        base_url = 'http://' + base_url
        printVerbose('url is ' + base_url)
        conn = restful_lib.Connection(base_url, username=args.login, password=args.password)
        headers = {'content-type':'text/json', 'accept':'text/json'}
        conn.request_post("/bynewnancy", args={'q': 'Test'}, headers=headers)
        #conn.request_get("/bynewnancy", args=content, returns=conn.ret, headers={'Accept': 'text/json'})

# MAIN

#definition des variables
if __name__ == '__main__':

    #parse command line arguments
    parser = argparse.ArgumentParser()

    parser.add_argument('-v', dest='verbose', action='store_true')
    parser.add_argument('-bt', '--nancyTargetID', required=True)
    parser.add_argument('-bu', '--nancyUrl', required=True)
    parser.add_argument('-bv', '--nancyVersion', required=False)
    parser.add_argument('-p', '--projectID', required=True)
    parser.add_argument('-s', '--MumID', required=True)
    parser.add_argument('-u', '--userID', required=True)
    #parser.add_argument('-url', '--httpURL', default='127.0.0.1')
    #parser.add_argument('-port', '--httpPort', default='8080')
    #parser.add_argument('-login', '--login', default='admin')
    #parser.add_argument('-pwd', '--password', default='admin')
    #parser.add_argument('-o', '--outputDir', default='.')

    #args is considered as a global variable
    args = parser.parse_args()


    postContent = postContent()
    callRestApi(postContent)

    print('----==============================---- ')
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T01:07:01+00:00Added an answer on June 6, 2026 at 1:07 am

    The restful_lib comes from http://code.google.com/p/python-rest-client, but its last change is 4 years ago, so I wouldn’t suggest using this package.

    I would strongly recommend the requests library for such a task. A POST request with XML data would simply look like this:

    requests.post(url, data=my_xml_string)
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
Does anyone know how can I replace this 2 symbol below from the string
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I'm trying to create an if statement in PHP that prevents a single post
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
Basically, what I'm trying to create is a page of div tags, each has
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have this code to decode numeric html entities to the UTF8 equivalent character.

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.