VBA Http Post Request - Postman Key/value/body Provided - Mr. Excel

MrExcel Message Board
  • Forums New posts Search forums Board Rules
  • What's new New posts New Excel articles Latest activity
  • New posts
  • Excel Articles Latest reviews Search Excel articles
  • MrExcel Publishing MrExcel Homepage MrExcel Bookstore MrExcel Seminars Excel Consulting Services
Log in Register What's new Search

Search

Everywhere Threads This forum This thread Search titles only By: Search Advanced search…
  • New posts
  • Search forums
  • Board Rules
Menu Log in Register Install the app Install How to install the app on iOS

Follow along with the video below to see how to install our site as a web app on your home screen.

Note: This feature may not be available in some browsers.

  • If you would like to post, please check out the MrExcel Message Board FAQ and register here. If you forgot your password, you can reset your password.
  • Forums
  • Question Forums
  • General Discussion & Other Applications
You are using an out of date browser. It may not display this or other websites correctly.You should upgrade or use an alternative browser. VBA http Post Request - Postman key/value/body provided
  • Thread starter bensko
  • Start date Oct 23, 2018
  • Tags api http post json postman sendhub
B

bensko

Board Regular
Joined Mar 4, 2008 Messages 173 Hi All, I have been working on this for days without success. Even downloaded VBA-WEB and looked at examples there, online and everywhere. I can't seem to get this figured out and I have been working with VBA code for 15 years. I am pretty new at API but Postman makes things pretty easy. I POST 30-40 schedule work orders a day into Tsheets. Use it do add staff, GET logs to run margin reports, and a variety of other tasks. I also am able, through Postman, to send a text message to my customers through our SendHub Voip service (see code below). What I am trying to do now though is send a survey request text (with link) to 30-40 clients at the end of each day. Since the message content will include a different web link for each staff member (they each have their own quality survey Google form) I can't bulk send to multiple phone numbers in Postman. Each message has to be unique so I am going to loop through my schedule worksheet, collect phone numbers ,date, and form link, on a "Survey" sheet, then call the Http POST request code to send them one at a time. http://apidocs.sendhub.com/ the data below is what the postman code looks like to POST to SendHub. I can PM someone my username and Key if needed to test. POST /v1/messages/?username=847380XXXX&api_key=8f467647fd4a96a1345d1e45192381bc19XXXXXX HTTP/1.1 Host: api.sendhub.com Content-Type: application/json Cache-Control: no-cache Postman-Token: 38caba79-adfb-4e9b-b2ed-2cf72XXXXXX Code: { "contacts": [ "+17085257848" ], "text": "Please take two seconds to rate your 10/20/18 service: https://goo.gl/forms/***4WSEGSfib6KJG3 } Here is the code to cycle through the schedule: Code: Sub Surveys_Monday() Range("C4").Select GoTo 14 12 ActiveCell.Offset(2, 0).Select If Range("BE" & ActiveCell.Row).Value = 10 Then ActiveCell.Offset(-8, 2).Select End If If ActiveCell.Column = 53 Then GoTo 20 End If 14 If ActiveCell.Value = "" Or Left(ActiveCell.Value, 1) = ">" Then GoTo 12 Else End If Dim Sh1 As Worksheet, Sh2 As Worksheet Set Sh1 = Sheets("Survey") Set Sh2 = Sheets("Schedule") Sh1.Range("C2").Value = ActiveCell.Value Sh1.Range("D2").Value = Sh2.Cells(2, ActiveCell.Column).Value Sh1.Range("E2").Value = Range("BA" & ActiveCell.Row).Value Sh1.Select Send_To_SendHub (see below) '''''''API CODE TO TEXT TO CLIENT '''''''' GoTo 12 20 End Sub '''' I have no idea if below is the right code to use, found it online somewhere and it seems to be pretty close to what I need with my Key, Header, etc. Code: Sub Send_To_SendHub() Dim sURL As String, sHTML As String, sAllPosts As String Dim oHttp As Object Dim blWSExists As Boolean Dim Body As String ''''Not sure how to code the body below. The Date would be located on the "Survey" sheet in E2, Phone number in F2, and Form Link in G2. Other text can be placed in H2, I2, etc. or Kept in the code. Body = { "contacts": [ "+17085257848" ], "text": "Please take two seconds to rate your 10/20/18 service: https://goo.gl/forms/***4WSEGSfib6KJG3 } Set oHttp = CreateObject("MSXML2.XMLHTTP") sURL = "https://api.sendhub.com/v1/messages/?username=847380XXXX&api_key=8f467647fd4a96a1345d1e45192381bc19XXXXXX" oHttp.Open "POST", sURL, False oHttp.setRequestHeader "Content-type", "application/json" oHttp.setRequestHeader "Accept", "application/json" Http.Send Body sHTML = oHttp.ResponseText Worksheets("Response").Range("A1").Value = sHTML 'will write additional code to clean this up into a list of surveys sent. End Sub I sincerely appreciate any guidance that can be provieded. Ben

Excel Facts

Which lookup functions find a value equal or greater than the lookup value? Click here to reveal answer MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted. You must log in or register to reply here.

Similar threads

P
  • Question
Make an api call to geoTab to get current location of the vehicle in VBA. Tried few codes but nothing seem to work. Any help is appreciated.
  • Pardeep Singh
  • Feb 11, 2023
  • Excel Questions
Replies 0 Views 1K Feb 11, 2023 Pardeep Singh P kelly mort
  • Question
VBA code to send sms from a website amendment needed
  • kelly mort
  • Mar 3, 2023
  • Excel Questions
2 3 Replies 28 Views 2K Jun 7, 2023 Abren A T
  • Question
Power Query Post Web Form Data
  • Tiger9136
  • Jun 16, 2021
  • Power Tools
Replies 0 Views 973 Jun 16, 2021 Tiger9136 T N
  • Question
How do I write tickets to Zendesk API using POST JSON requests in VBA?
  • nhumensky
  • Feb 12, 2020
  • Excel Questions
Replies 1 Views 4K Mar 17, 2020 smozgur smozgur W
  • Question
VBA Code to reject value in sheet1 if already in sheet2 and if not in sheet 2 move the said value to sheet 3 and send email to client
  • WillemS
  • Jul 21, 2021
  • Excel Questions
Replies 1 Views 617 Jul 21, 2021 offthelip O Share: Facebook X (Twitter) Reddit Pinterest Tumblr WhatsApp Email Share Link

Forum statistics

Threads 1,218,234 Messages 6,141,310 Members 450,347 Latest member Santoli3

Share this page

Facebook X (Twitter) Reddit Pinterest Tumblr WhatsApp Email Share Link
  • Forums
  • Question Forums
  • General Discussion & Other Applications

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock1)Click on the icon in the browser’s toolbar.2)Click on the icon in the browser’s toolbar.2)Click on the "Pause on this site" option. Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus1)Click on the icon in the browser’s toolbar.2)Click on the toggle to disable it for "mrexcel.com". Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin1)Click on the icon in the browser’s toolbar.2)Click on the "Power" button.3)Click on the "Refresh" button. Go back

Disable uBlock

Follow these easy steps to disable uBlock1)Click on the icon in the browser’s toolbar.2)Click on the "Power" button.3)Click on the "Refresh" button. Go back Continue without adsI've disabled my adblock Back Top

Từ khóa » Visual Basic Excel Send Http Request