How to with ASP and XMLHTTP

Victor B's Avatar

Victor B

26 Apr, 2010 03:11 AM via web

I am trying to access with the following code, but get an error:



Set xml = Server.CreateObject("Microsoft.XMLHTTP")

    xml.Open "POST", "https://www.imified.com/api/bot/", False,"username", "password
    xml.setRequestHeader "Authorization", "Basic " & base64_encode("username;password")
    xml.Send "botkey=botkeygoeshere&apimethod=getAllUsers"

Response.Write xml.responseText

  1. Support Staff 2 Posted by Danté Vitulano on 26 Apr, 2010 12:34 PM

    Danté Vitulano's Avatar

    Hello,

    I am afraid that I am not terribly familiar with ASP myself, but if you can tell me exactly what error you are getting, I may be able to determine what the cause is.

    ~Dante

  2. 3 Posted by VictorB on 26 Apr, 2010 02:19 PM

    VictorB's Avatar



  3. 4 Posted by Dave Hoff on 27 Apr, 2010 05:40 PM

    Dave Hoff's Avatar

    Not sure what is going on here. I have tested the getAllUsers API call and
    it is working as it should. That error is returned only when the username,
    password, and botkey do not validate.

    Dave

  4. 5 Posted by Victor Brief on 27 Apr, 2010 06:02 PM

    Victor Brief's Avatar

    And what code are you using? Do you have a sample.

  5. 6 Posted by Dave Hoff on 29 Apr, 2010 04:34 PM

    Dave Hoff's Avatar

    We have a PHP sample on the docs page. I don't have an IIS server to test
    this with but as long as your using basic auth correctly it should work.

  6. 7 Posted by Victor Brief on 29 Apr, 2010 04:48 PM

    Victor Brief's Avatar

    The PHP version of the code works, but the ASP doesn't, hence my support
    question.

  7. 8 Posted by rob on 12 May, 2010 01:53 AM

    rob's Avatar

    Hi Guys,

    I might be able to help -- I've put together a sample poster.
    I believe the trick was setting the correct content-type. Railo? must not be able to understand the post if it's not specified.

    I've attached the sample in classic asp, and i've tested it. Of course, now i feel slightly dirty as i haven't wrote new asp in about 8 years.

    Cheers,
    Rob.

    == ps, here is the snippet, in case you dont want to download this:

    <!--#include virtual="encode.asp"-->
    <%
    Set xml = Server.CreateObject("MSXML2.ServerXMLHTTP")
    imifiedUsername = "YOUR USERNAME"
    imifiedPassword = "YOUR PASSWORD"
    botKey = "A BOT KEY GUID"
    apiMethod = "getAllUsers"
    
    xml.Open "POST", "https://www.imified.com/api/bot/", False
    xml.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"    
    xml.setRequestHeader "Authorization", "Basic " &         base64_encode(imifiedUsername & ":" & imifiedPassword)
    xml.Send "botkey=" & botkey & "&apimethod=" & apiMethod
    Response.Write xml.responseText
    
    %>
    
  8. 9 Posted by mlucas on 19 Oct, 2010 03:28 PM

    mlucas's Avatar

    @Victor Brief Did the code that "rob" posted help? Is this still a current issue that you are having? I will be monitoring this page and look forward to helping you with your issue.

    -Matt Lucas
    IMified Support

  9. 10 Posted by Stephen Connell on 20 Feb, 2011 05:56 PM

    Stephen Connell's Avatar

    To get the sample code to work i had to add an equals sign to the end of the string provided by the base64_encode function.
    I added & "=" to the end of this line:
    xml.setRequestHeader "Authorization", "Basic " & base64_encode(imifiedUsername & ":" & imifiedPassword) & "="

    and the code worked properly.
    Thanks, Stephen

  10. 11 Posted by jkulnis on 27 Feb, 2011 02:56 PM

    jkulnis's Avatar

    Using Classic ASP, i get a 200 response but no text going out to the phone number. Any assistance would be nice. thanks.

    var objHTTP = Server.CreateObject("MSXML2.XMLHTTP");
    var vURL = "https://www.imified.com/api/bot/"
    var vBotAll = "botkey=MyBotKey&apimethod=send$user=MyCellNo&msg=MyMsg
    objHTTP.Open("POST", vURL, false)
    objHTTP.setRequestHeader("Authorization", "Basic " + "MyUser:MyPassword") // This is replaced with the encode but Imified doesnt give me a user name so assuming it is my email address
    objHTTP.setRequestHeader("Content-type", "application/x-www-form-urlencoded")
    objHTTP.Send(vBotAll)
    objHTTP = null

  11. 12 Posted by Dave Hoff on 07 Mar, 2011 04:01 PM

    Dave Hoff's Avatar

    Do you get back the expected xml response in the body from IMified?

    On Sun, Feb 27, 2011 at 9:56 AM, jkulnis <
    ***@tenderapp.com> wrote:

Reply to this discussion

Internal reply

Formatting help or Preview

Attached Files

You can attach files up to 10MB

If you don't have an account yet, we need to confirm you're human and not a machine trying to post spam.