Hi,
Please I need your help. I try to communicate with a site using their API
the site explains explicitly how to do it:
NFIB[
^]
I always get error message "error:context null, No application name header or parameter value in request, code 400."
I think i may have problem with set request header or the body.
below is my code
What I have tried:
Option Explicit
Sub testAPI()
Dim Body, line1, line2, line3, line4, line5, line6, line7, line8, line9, line10 As String
Dim request As New MSXML2.ServerXMLHTTP60
request.Open "POST", "http://open.api.nfib-sbet.org/rest/sbetdb/_proc/getIndicators", False
request.SetRequestHeader "Content-type", "application/json"
request.SetRequestHeader "Accept", "application/json"
line1 = "{"
line2 = """app_name"": ""sbet"","
line3 = """params"": ["
line4 = "{ ""name"": ""minYear"", ""param_type"": ""IN"", ""value"": 2010 },"
line5 = "{ ""name"": ""minMonth"", ""param_type"": ""IN"", ""value"": 6 },"
line6 = "{ ""name"": ""maxYear"", ""param_type"": ""IN"", ""value"": 2010 },"
line7 = "{ ""name"": ""maxMonth"", ""param_type"": ""IN"", ""value"": 12 },"
line8 = "{ ""name"": ""indicator"", ""param_type"": ""IN"", ""value"": ""OPT_INDEX"" }"
line9 = "]"
line10 = "}"
<pre>Body = line1 & line2 & line3 & line4 & line5 & line6 & line7 & line8 & line9 & line10
request.Send Body
If request.Status <> 200 Then
MsgBox request.ResponseText
Exit Sub
End If
End Sub