Cannot write data using write-api
Hi, I have some data (username/topic.etc.) and I want to put these into forum using write-api.
curl -H "Authorization: Bearer token here"
--data "username=helloa&password=accccc&[email protected]" http://myhost:4567/api/v1/users
It works and others like topic,post,category also works.
2, Because my data is in excel, so I want use VBA to do this.
I tried two different function in excel VBA and it comes out same error.
Below are VBA code and error.
It seems that the server dosen't get the data.
I am so confused....Can you point out me my error.
I'm not professional in coding. Now I have successfully generated my users on nodebb from the EXCEL data. Guys you may think it is so easy and can be done by serval codes，but it's quite hard for me to understand the http protocols and programing think.
And now thank you I can do it myself.
Here is the code of generating new users on EXCEL VBA. Hope it can help people like me. ; )
Sub newusername() Dim i As Integer Dim data, user, pass, mail As String Dim XMLHTTP As New MSXML2.XMLHTTP, myurl As String myurl = "http://yourhost/api/v1/users/" For i = 6 To 8 user = "username=" & Cells(i, 1) pass = "&password=" & Cells(i, 2) mail = "&email=" & Cells(i, 4) data = user + pass + mail XMLHTTP.Open "POST", myurl, False XMLHTTP.setRequestHeader "Authorization", "Bearer yourtoken" XMLHTTP.setRequestHeader "Content-type", "application/x-www-form-urlencoded" XMLHTTP.Send data Debug.Print (XMLHTTP.responseText) Next End Sub
Here I set
ias the row, and I put username, password and email in column A,B,and D.
Thank you again!