Improve company productivity with a Business Account.Sign Up


RestService post Json data

Posted on 2013-01-23
Medium Priority
Last Modified: 2013-01-25

I have succesfully manged to use GET to read data from a restservice and am now attempting to POST data to the same service. I have a class which I am converting to json data but I am unsure of how to attach the data to the webrequest. The code is below can anyone advise me?

The Data:

{"text":"Trial from desktop","userID":"JOE","account":"systems","read":"False","subject":"Test","inout":"in"}

The Code correct credentials used in my app:

Private Sub tiggzipost()
        Dim request As HttpWebRequest
        Dim response As HttpWebResponse = Nothing
        Dim reader As StreamReader
        Dim message As New Message()
        message.text = "Trial from desktop"
        message.userID = "JOE"
        message.account = "systems" = "false"
        message.subject = "Test"
        message.inout = "in"
        Dim output As String = JsonConvert.SerializeObject(message)

            request = DirectCast(WebRequest.Create (""), HttpWebRequest)
            request.Credentials = New NetworkCredential("XXXXX", "XXXXX")

            request.Method = "POST"
            request.ContentType = "application/json"

            response = DirectCast(request.GetResponse(), HttpWebResponse)

            reader = New StreamReader(response.GetResponseStream())

            If Not response Is Nothing Then response.Close()
        End Try
    End Sub
Question by:JoeBo747
LVL 83

Accepted Solution

CodeCruiser earned 2000 total points
ID: 38812226

Author Closing Comment

ID: 38819610
Help me get to the bottom of the problem.

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

How to build a simple, quick and effective accordion menu using just 15 lines of jQuery and 2 css classes
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…

569 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question