Advertisement
Guest User

Untitled

a guest
Sep 7th, 2018
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Function submit_call(endpoint, verb, data, apiKey)
  2.         Dim bpreq, post_response
  3.         Set bpreq = server.CreateObject("MSXML2.ServerXMLHTTP.6.0")
  4.  
  5.         bpreq.Open verb, endpoint, False
  6.  
  7.         'if not (verb = "POST") then
  8.        '    bpreq.SetRequestHeader "X-HTTP-Method-Override", verb
  9.       ' end if
  10.  
  11.         bpreq.SetRequestHeader "Content-Type", "application/json"
  12.         bpreq.SetRequestHeader "Authorization", "apikey " & apiKey
  13.    
  14.         On Error Resume Next
  15.         bpreq.Send(data)
  16.  
  17.         If Err.Number = 0 Then
  18.             If bpreq.Status = "200" Then
  19.               submit_call = bpreq.ResponseText
  20.             Else
  21.               submit_call = "Endpoint: " & endpoint & ", HTTP " & bpreq.Status & " " & bpreq.StatusText
  22.             End If
  23.         Else
  24.             submit_call = "Error " & Err.Number & " " & Err.Source & " " & Err.Description
  25.         End If
  26.         On Error GoTo 0
  27.         Set bpreq = Nothing
  28.     End function
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement