0

Some time ago I started to use the api call system of Ahsay and wasn't that difficult to understand.

In the webbrowser the API call works, but when I try to use C# only a part seems to get to Ahsay?

I'm using this code of CodeProject to do the API call: http://www.codeproject.com/Tips/497123/How-to-make-REST-requests-with-Csharp

In this code I send as API call:

{SysUser: system, SysPwd: system, LoginName: test, Owner: , Password: test}

and get as error code:

<err>[Error] Parameter LoginName is null/empty!</err>

If I sent the same requist as an URL like:

http://SERVERIP/obs/api/AuthUser.do?SysUser=system&SysPwd=system&LoginName=test&Password=test` 

it gives as error code: <err>[Error] The password must be at least 6 characters in length!</err>

Can somebody explain to me why the LoginName isn't send or received in the C# code?

DavidG
  • 113,891
  • 12
  • 217
  • 223
Quispie
  • 948
  • 16
  • 30
  • Hard to tell exactly what you are doing in the first method, but looks like you are POSTing some JSON data and the second is an HTTP GET with a query string. That's totally different things. What does the API support? – DavidG Nov 21 '14 at 10:22
  • The support for the API isn't really clear. If I look at the API guide it looks like XML. But if I send it the wrong way, why do I get a part of an answer? – Quispie Nov 21 '14 at 10:49
  • Is the API guide available? – DavidG Nov 21 '14 at 10:49
  • https://www.google.nl/url?sa=t&rct=j&q=&esrc=s&source=web&cd=2&ved=0CCkQFjAB&url=http%3A%2F%2Fwww.ahsay.com%2Fdownload%2Fdownload_document.jsp%3FdocumentName%3Dobs_admin&ei=TBlvVMTOGoXROuD2gRg&usg=AFQjCNF41jvvp0KP7CM7B9P-83YcnDiyfw&sig2=lLp_WdvonYgMQ7U0Ei2Uog&bvm=bv.80185997,d.ZWU&cad=rja – Quispie Nov 21 '14 at 10:52
  • Nothing unclear in there. Your first version is not how they expect the results so I'd stick with the second. – DavidG Nov 21 '14 at 10:56
  • It works now, I had to use only HTTP and not JSON. It works now, thanks! http://stackoverflow.com/questions/943852/how-to-send-an-https-get-request-in-c-sharp – Quispie Nov 21 '14 at 10:57

1 Answers1

0

If someone encounters the same problem, here is the code I's using:

public void API_HTTP()
   {
    string url = "http://URL";

    HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

    HttpWebResponse response = (HttpWebResponse)request.GetResponse();

    Stream resStream = response.GetResponseStream();
    StreamReader reader = new StreamReader(resStream);
    String output = reader.ReadToEnd();

            }
Quispie
  • 948
  • 16
  • 30