Click here to Skip to main content
15,921,279 members
Home / Discussions / C#
   

C#

 
AnswerRe: WPF assembly in C# Pin
OriginalGriff30-Oct-17 20:37
mveOriginalGriff30-Oct-17 20:37 
AnswerRe: WPF assembly in C# Pin
Gerry Schmitz31-Oct-17 12:17
mveGerry Schmitz31-Oct-17 12:17 
GeneralRe: WPF assembly in C# Pin
peterkmx2-Nov-17 6:29
professionalpeterkmx2-Nov-17 6:29 
QuestionEnum of C# Data Types - byte[] and char[] Pin
Kevin Marois30-Oct-17 12:30
professionalKevin Marois30-Oct-17 12:30 
GeneralRe: Enum of C# Data Types - byte[] and char[] Pin
Sascha Lefèvre30-Oct-17 14:06
professionalSascha Lefèvre30-Oct-17 14:06 
GeneralRe: Enum of C# Data Types - byte[] and char[] Pin
Kevin Marois31-Oct-17 4:56
professionalKevin Marois31-Oct-17 4:56 
GeneralRe: Enum of C# Data Types - byte[] and char[] Pin
Sascha Lefèvre31-Oct-17 5:20
professionalSascha Lefèvre31-Oct-17 5:20 
QuestionConvert an obsolete old REST documentation Pin
Member 1096750730-Oct-17 0:54
Member 1096750730-Oct-17 0:54 
Hey guys.

I'm struggling to use a REST API. My Problem is that only available documentation for this API is too old and it is not supported in newer versions of .net

Please help me to convert it, here is the documentation:

C#
// Using "WCF REST Starter Kit" (http://msdn.microsoft.com/en-us/netframework/cc950529.aspx)
using (var client = new HttpClient("http://rt.site.com/REST/1.0/"))
{
   client.TransportSettings.Cookies = new CookieContainer();

   var form = new HttpUrlEncodedForm();
   form.Add("user", "LOGIN");
   form.Add("pass", "PASSWORD");

   client.Post(string.Empty, form.CreateHttpContent());

   // 1. Get ticket data
   using (var request = client.Get("ticket/1234/show"))
   {
      string content = request.Content.ReadAsString();
      // Some logic
   }

   // 2. Post ticket reply with attachment
   var formPost = new HttpMultipartMimeForm();
   byte[] attachment = new byte[];
   string content = string.Empty;
         
   // Store data in attachment
   // Store data in content string ("Field: Value" line by line)
   // ...
         
   formPost.Add("content", content);
   formPost.Add("attachment_1", "attachment_1", HttpContent.Create(attachment, "application/octet-stream"));
                             
   using (var post = client.Post("ticket/1234/comment"), formPost.CreateHttpContent()))
      // Some logic
}


And here is what I have done so far:

C#
var credentials = new NetworkCredential(name, pass);
CookieContainer CookieContainer = new CookieContainer();
var handler = new HttpClientHandler {CookieContainer = CookieContainer,  Credentials = credentials };
using (var client = new HttpClient(handler))
{

    client.BaseAddress = new Uri("https://something.net");

    var form = new List<KeyValuePair<string, string>>();
    form.Add(new KeyValuePair<string, string>("user", name));
    form.Add(new KeyValuePair<string, string>("pass", pass));

    var request = new HttpRequestMessage(HttpMethod.Post, "/rt/REST/1.0");

    request.Content = new FormUrlEncodedContent(form);

    var response = await client.SendAsync(request);

    var contents = await response.Content.ReadAsStringAsync();


Please note to this comment:

The REST Interface does not support HTTP-Authentication. So you must get a valid Session-Token and submit the cookie each request. You usually get a Session-Cookie by submitting the default login form. Use variables "user" for login and "pass" for password values

Thank you very much
QuestionHow calculate Checksum for barcode code128 auto? Pin
Le@rner29-Oct-17 20:01
Le@rner29-Oct-17 20:01 
AnswerRe: How calculate Checksum for barcode code128 auto? Pin
Richard MacCutchan29-Oct-17 22:27
mveRichard MacCutchan29-Oct-17 22:27 
AnswerRe: How calculate Checksum for barcode code128 auto? Pin
Sascha Lefèvre29-Oct-17 22:27
professionalSascha Lefèvre29-Oct-17 22:27 
QuestionNo overload for method, error in c# file for Unity. Pin
Member 1349123628-Oct-17 14:33
Member 1349123628-Oct-17 14:33 
AnswerRe: No overload for method, error in c# file for Unity. Pin
Sascha Lefèvre28-Oct-17 14:47
professionalSascha Lefèvre28-Oct-17 14:47 
PraiseRe: No overload for method, error in c# file for Unity. Pin
Member 1349123628-Oct-17 15:25
Member 1349123628-Oct-17 15:25 
QuestionC# Problem extracting file from .zip created with DotNetZip Pin
manic_drummer28-Oct-17 11:58
manic_drummer28-Oct-17 11:58 
AnswerRe: C# Problem extracting file from .zip created with DotNetZip Pin
Sascha Lefèvre28-Oct-17 13:35
professionalSascha Lefèvre28-Oct-17 13:35 
AnswerRe: C# Problem extracting file from .zip created with DotNetZip Pin
Bernhard Hiller30-Oct-17 4:18
Bernhard Hiller30-Oct-17 4:18 
Questionc#Move music files in listbox up or down Pin
Member 1348924427-Oct-17 5:00
Member 1348924427-Oct-17 5:00 
AnswerRe: c#Move music files in listbox up or down Pin
Richard MacCutchan27-Oct-17 5:11
mveRichard MacCutchan27-Oct-17 5:11 
GeneralRe: c#Move music files in listbox up or down Pin
Member 1348924427-Oct-17 5:18
Member 1348924427-Oct-17 5:18 
GeneralRe: c#Move music files in listbox up or down Pin
Richard MacCutchan27-Oct-17 5:51
mveRichard MacCutchan27-Oct-17 5:51 
GeneralRe: c#Move music files in listbox up or down Pin
Member 1348924427-Oct-17 6:18
Member 1348924427-Oct-17 6:18 
GeneralRe: c#Move music files in listbox up or down Pin
Richard MacCutchan27-Oct-17 6:42
mveRichard MacCutchan27-Oct-17 6:42 
SuggestionRe: c#Move music files in listbox up or down Pin
Ralf Meier28-Oct-17 12:20
mveRalf Meier28-Oct-17 12:20 
GeneralRe: c#Move music files in listbox up or down Pin
Richard MacCutchan28-Oct-17 22:08
mveRichard MacCutchan28-Oct-17 22:08 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.