Account Options

  1. Sign in
The old Google Groups will be going away soon, but your browser is incompatible with the new version.
Google Groups Home
« Groups Home
Performing a GET on the REST API works but a POST fails
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  8 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Max Foulds  
View profile  
 More options Oct 3 2012, 7:50 am
From: Max Foulds <maxfoul...@gmail.com>
Date: Wed, 3 Oct 2012 04:50:44 -0700 (PDT)
Local: Wed, Oct 3 2012 7:50 am
Subject: Performing a GET on the REST API works but a POST fails

I am trying to create a Bug but using the following POST fails with a 401
when a GET does authenticate. I appreciate this is fundamentally a write
rather than a read but the AD user role does have Add/Edit permissions.
what am i missing?

Thanks

        private static XmlDocument restPost(string url, string userName, string userPassword, string domain, string xmlPost)
        {
            var request = WebRequest.Create(new Uri(url)) as HttpWebRequest;
            var xd = new XmlDocument();
            if (request != null)
            {
                request.Method = WebRequestMethods.Http.Post;
                string postData = string.Format(xmlPost);
                byte[] data = Encoding.UTF8.GetBytes(postData);

                request.ContentType = "application/xml";
                request.ContentLength = data.Length;

                using (Stream requestStream = request.GetRequestStream())
                {
                    requestStream.Write(data, 0, data.Length);
                }
                request.Credentials = new NetworkCredential(userName, userPassword, domain);
                request.PreAuthenticate = true;
                var response = request.GetResponse() as HttpWebResponse;
                var reader = new StreamReader(response.GetResponseStream());
                xd.LoadXml(reader.ReadToEnd());
            }
            return xd;
        }


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alex Fomin  
View profile  
 More options Oct 5 2012, 8:48 am
From: Alex Fomin <shurickfo...@gmail.com>
Date: Fri, 5 Oct 2012 05:48:31 -0700 (PDT)
Local: Fri, Oct 5 2012 8:48 am
Subject: Re: Performing a GET on the REST API works but a POST fails

Hi Max,

You code is correct. Do you use on-demand or on-site TP? What value do you
pass to "domain" parameter? What is the body of a 401 response?

Thanks,
Alex


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Max Foulds  
View profile  
 More options Oct 18 2012, 4:55 am
From: Max Foulds <maxfoul...@gmail.com>
Date: Thu, 18 Oct 2012 01:55:45 -0700 (PDT)
Local: Thurs, Oct 18 2012 4:55 am
Subject: Re: Performing a GET on the REST API works but a POST fails

We are using on-site TP and I am passing in the fully qualified domain name
into the post


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alex Fomin  
View profile  
 More options Oct 18 2012, 7:23 am
From: Alex Fomin <shurickfo...@gmail.com>
Date: Thu, 18 Oct 2012 04:23:59 -0700 (PDT)
Local: Thurs, Oct 18 2012 7:23 am
Subject: Re: Performing a GET on the REST API works but a POST fails

Do you use win authentication? If so, what is the body of 401 response?


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Max Foulds  
View profile  
 More options Oct 18 2012, 11:53 am
From: Max Foulds <maxfoul...@gmail.com>
Date: Thu, 18 Oct 2012 08:53:08 -0700 (PDT)
Local: Thurs, Oct 18 2012 11:53 am
Subject: Re: Performing a GET on the REST API works but a POST fails

Yes we are using win authentication and It is responding with a "The remote
server returned an error: (401) Unauthorized."

Just to clarify, the same account has no problems doing a request before it
tries a post.


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Max Foulds  
View profile  
 More options Oct 18 2012, 11:54 am
From: Max Foulds <maxfoul...@gmail.com>
Date: Thu, 18 Oct 2012 08:54:57 -0700 (PDT)
Local: Thurs, Oct 18 2012 11:54 am
Subject: Re: Performing a GET on the REST API works but a POST fails

That was meant to say no problem doing a GET before it tries to POST :)


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Alex Fomin  
View profile  
 More options Nov 8 2012, 3:33 am
From: Alex Fomin <shurickfo...@gmail.com>
Date: Thu, 8 Nov 2012 00:33:56 -0800 (PST)
Local: Thurs, Nov 8 2012 3:33 am
Subject: Re: Performing a GET on the REST API works but a POST fails

Hi Max,

We still need a full body of 401 response including all headers to
determine whether this response is caused by IIS itself (that means that
there is some issues with IIS configs) or by TP (in case of bugs). Also
have you tried to send POST requests with 3rd party tools like Fiddler? It
will insert required Windows credentials if IIS is configured correctly.
Also you can sniff the full IIS response using fiddler as well.

If you have any issues with capturing the response body, please contact our
support
at http://messenger.providesupport.com/messenger/targetprocess.html?ps_s...
so we can do this in live chat session,

Thanks,
Alex, TP Team


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Max Foulds  
View profile  
 More options Nov 8 2012, 10:02 am
From: Max Foulds <maxfoul...@gmail.com>
Date: Thu, 8 Nov 2012 07:02:51 -0800 (PST)
Local: Thurs, Nov 8 2012 10:02 am
Subject: Re: Performing a GET on the REST API works but a POST fails

Alex

Thanks for the direct toward sniffing at the post. It enabled me to get to
the bottom of the problem which was 2 fold. My code that I had posted above
was incorrect in that the 2 following lines should have been further up the
method logic

                request.Credentials = new NetworkCredential(userName, userPassword, domain);
                request.PreAuthenticate = true;

I noticed that there was a post which failed with "401 - Unauthorized:
Access is denied due to invalid credentials" with an empty negotiation
string and then there was a second post using a encoded negotiation string
which then successfully authenticated however my XML was badly formed as I
got a bad response which I managed to fix. Anyway problem now solved. See
below for my updated working REST post

        private static XmlDocument restPost(string url, string userName,
string userPassword, string domain, string xmlPost)
        {
            var request = WebRequest.Create(new Uri(url)) as HttpWebRequest;
            var xd = new XmlDocument();
            if (request != null)
            {
                request.Method = WebRequestMethods.Http.Post;
                string postData = string.Format(xmlPost);
                byte[] data = Encoding.UTF8.GetBytes(postData);

                request.ContentType = "application/xml; charset=utf-8";
                request.ContentLength = data.Length;
                request.Credentials = new NetworkCredential(userName,
userPassword, domain);
                request.PreAuthenticate = true;

                using (Stream requestStream = request.GetRequestStream())
                {
                    requestStream.Write(data, 0, data.Length);
                }
                var response = request.GetResponse() as HttpWebResponse;
                var reader = new StreamReader(response.GetResponseStream());
                xd.LoadXml(reader.ReadToEnd());
            }
            return xd;
        }


 
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »