Limesurvey JSON POST VBA

3 months 1 week ago #163924 by micmoo
micmoo created the topic: Limesurvey JSON POST VBA
I am trying to have access to my survey using ms access and JSON request. I am aware there is plenty of examples on the web (focused on getting data from and to MS Excel). They give great insight in the Json parsing. However I am trying to send a simple POST request to a survey using VBA but for a reason I do not understand I can not get even the session ID.

Here is the code :
Dim JSRequest As New XMLHTTP60
JSRequest.Open "POST", " "
JSRequest.setRequestHeader "Content-type:", "application/json"
JSRequest.setRequestHeader "method:", "get_session_key"
JSRequest.setRequestHeader "params:", "[" & """mysusername""" & "," & """mypassword""" & "]"
JSRequest.setRequestHeader "id:", 1
If JSRequest.status = 200 Then
Debug.Print JSRequest.GetAllResponseHeaders
Debug.Print "responseBody = " & JSRequest.ResponseBody
Debug.Print "responsetext = " & JSRequest.ResponseText
End If
Exit Sub

I am getting the status = 200 but I get the following response :
responseBody = ?????????????????????????????????
responsetext = {"id":null,"result":null,"error":"unable to decode malformed json"}

I suspect that the string related to the user/pwd is not correct but I could not find the correct string (the string below will give - ["mysusername","mypassword"] -. I have tried different strings using fiddler but without success. Did I miss something ?

Would be grateful if somebody could help

Thanks in advance

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

Start now!

Just create your account and start using Limesurvey today.

Register now
Join our Newsletter!