Obtain Token from LimeSurvey Using VBA

More
3 months 6 days ago #181907 by websolprov
Dear Friends,

I have a macro system in Excel that does other update tasks for internal records, and I want to (at the end of the process) send out a LimeSurvey to the recipient of the update. I want to use VBA to obtain a token from Lime and then use this to generate an email from within VBA containing the unique link.

I cant get the API to return the session_key despite trying everything I cant get anything to return. This is the current version of code I am using. I dont get any errors, receive the status code = 200 but the response is empty:

Sub GetData()
Dim objHTTP As Object
Dim arrJSON As Variant, strJSON As String
Set objHTTP = CreateObject("MSXML2.ServerXMLHTTP")
Url = "http://[website URL obscured]/survey/index.php/admin/remotecontrol"
objHTTP.Open "POST", Url, False
objHTTP.SetRequestHeader "Content-Type", "application/json"
strJSON = "{""method"":""get_session_key"",""username"":""*obscured username*"",""password"":""*obscured password*""}"

objHTTP.send (strJSON)

Debug.Print objHTTP.Status
If objHTTP.Status = "200" Then
MsgBox (objHTTP.responseText)
End If

End Sub

Please Log in or Create an account to join the conversation.

LimeSurvey Partners

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!