VBA Http Post Request - Postman Key/value/body Provided - Mr. Excel
Có thể bạn quan tâm
![MrExcel Message Board](/board/styles/mrexcel/mrexcel-logo.png)
- 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 Homepage MrExcel Bookstore MrExcel Seminars Excel Consulting Services
Search
Everywhere Threads This forum This thread Search titles only Search Advanced search…- New posts
- Search forums
- Board Rules
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
- Thread starter bensko
- Start date Oct 23, 2018
- Tags api http post json postman sendhub
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. BenExcel 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
- Pardeep Singh
- Feb 11, 2023
- Excel Questions
![kelly mort](/board/data/avatars/s/401/401365.jpg?1573883269)
- Question
- kelly mort
- Mar 3, 2023
- Excel Questions
- Question
- Tiger9136
- Jun 16, 2021
- Power Tools
- Question
- nhumensky
- Feb 12, 2020
- Excel Questions
![smozgur](/board/data/avatars/s/0/613.jpg?1710422615)
- Question
- WillemS
- Jul 21, 2021
- Excel Questions
Forum statistics
Threads 1,218,234 Messages 6,141,310 Members 450,347 Latest member Santoli3Share this page
Facebook X (Twitter) Reddit Pinterest Tumblr WhatsApp Email Share Link- Forums
- Question Forums
- General Discussion & Other Applications
![](https://www.mrexcel.com/img/sgw/logo.jpg)
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 MrExcelWhich adblocker are you using?
![AdBlock](https://www.mrexcel.com/img/sgw/ab_icon.png)
![AdBlock Plus](https://www.mrexcel.com/img/sgw/abp_icon.png)
![uBlock Origin](https://www.mrexcel.com/img/sgw/ubo_icon.png)
![uBlock](https://www.mrexcel.com/img/sgw/ub_icon.png)
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.![](https://www.mrexcel.com/img/sgw/ab_instructions.jpg)
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".![](https://www.mrexcel.com/img/sgw/abp_instructions.jpg)
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.![](https://www.mrexcel.com/img/sgw/ubo_instructions.jpg)
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.![](https://www.mrexcel.com/img/sgw/ub_instructions.jpg)
Từ khóa » Visual Basic Excel Send Http Request
-
How Can I Send An HTTP POST Request To A Server From Excel Using ...
-
Excel HTTP Get Request Using VBA | Excelerator.Solutions
-
Excel VBA Introduction Part 47.5 - Basic HTTP GET And ... - YouTube
-
HTTP POST API Using Excel/VBA - YouTube
-
How Send An HTTP POST Request To A Server From Excel Using VBA?
-
XmlHttpRequest - Http Requests In Excel VBA - Coding Is Love
-
Excel Vba Send HTTP POST To Server Code Example
-
VBA HTTP POST Requests With Google Forms Demo
-
VBA HTTP GET Requests With API And ServerXMLHTTP60
-
How To Apply VBA Macro API POST Method To HTTP Power Automate
-
Using Excel VBA To Send HTTP GET Request To Web Server
-
How Can I Send An HTTP POST Request To A Server From ... - Vue.js
-
Part 1: Send HTTP Request For Each Row In Excel Table
-
Pass Parameters In Vba Http Post Request