Nam Còi
  • Trang chủ
  • Lập Trình Website
  • Khóa Học
  • Động Lực
  • Tuyển Dụng
No Result
View All Result
  • Trang chủ
  • Lập Trình Website
  • Khóa Học
  • Động Lực
  • Tuyển Dụng
No Result
View All Result
Nam Còi
No Result
View All Result
Home Phần Mềm

Handling Vericlock Webhooks: Overcoming Challenges and Optimizing Costs

Nguyễn Hải Nam by Nguyễn Hải Nam
25/07/2024
in Phần Mềm, Software
70
Handling Vericlock Webhooks Post

Discover how we overcame unexpected challenges while integrating Vericlock webhooks at Prestige Lock and Door. Learn about the tricky JSON data formats, lack of API documentation, and our journey to a seamless, cost-effective solution.

0
SHARES
16
VIEWS

Integrating third-party services can sometimes feel like navigating a minefield. Recently, I encountered a tricky situation while integrating Vericlock webhooks at Prestige Lock and Door. Vericlock’s time-tracking service sent us JSON data containing nested and malformed fields, causing our webhook processing to fail. The primary issue was the unexpected data format and the lack of useful information from the Vericlock API Documentation. Here’s a breakdown of the problem and how I resolved it.

The Problem

Vericlock Logo

Initially, Vericlock sent data with the Content-Type: application/x-www-form-urlencoded instead of application/json. This discrepancy made it difficult to parse the data correctly. Even popular platforms like Make couldn’t handle the format properly. Only Zapier managed to process it without issues.

Additionally, the data included complex nested structures, especially within the customFields section. This section was causing parsing errors because it contained another JSON object that wasn’t properly closed. Here’s an example of the problematic data:

{
  "guid":"[REDACTED]",
  "rootGuid":"[REDACTED]",
  "employeeGuid":"[REDACTED]",
  "jobGuid":null,
  "jobCode":null,
  "jobName":null,
  "serviceItemGuid":null,
  "serviceItemCode":null,
  "serviceItemName":null,
  "serviceRatePennies":0,
  "start":"2024-07-15T21:40:00.000Z",
  "end":null,
  "duration":0,
  "clockInReportId":16913206,
  "inDetails":{
    "method":"api",
    "report":{
      "type":"text",
      "value":"1"
    },
    "ipAddress":"[REDACTED]",
    "geoTagging":{
      "error":"DeviceTimeout",
      "message":"A timeout error occurred on the device trying to retrieve GPS coordinates"
    },
    "customFields":":{
      "guid":"[REDACTED]",
      "name":"Vehicle",
      "type":"list",
      "listItemGuid":"[REDACTED]",
      "listItemName":"none",
      "listItemValue":4
    }:{
      "displayName":"Regular",
      "minutes":0,
      "timeTypeId":1
    },{
      "displayName":"Overtime 1",
      "minutes":0,
      "timeTypeId":2
    },{
      "displayName":"Overtime 2",
      "minutes":0,
      "timeTypeId":3
    }:""
  }
}

Notice the customFields section? It contained another JSON object that was not properly closed, leading to parsing errors.

The Solution

Prestige Lock and Door Logo

To handle this, I devised a solution that involved sanitizing the incoming JSON string before parsing it. Here’s how I did it:

1. Extract the Raw JSON String: The incoming data was stored as a string, which needed to be sanitized.

2. Remove the Problematic Section: By identifying the customFields segment, I stripped it from the string.

3. Parse the Cleaned String: Finally, the cleaned JSON string was parsed into a usable JSON object.

Here’s the code I used:

const express = require('express');
const bodyParser = require('body-parser');
const logger = require('./logger');

const app = express();
app.use(bodyParser.urlencoded({ extended: true }));

app.post('/webhook', async (req, res) => {
  const rawBody = req.body;
  logger.info(`Raw Body: ${JSON.stringify(rawBody)}`);

  const jsonString = Object.keys(rawBody)[0];
  const sanitizedString = jsonString.split(',"customFields":')[0] + "}}";
  const parsedData = JSON.parse(sanitizedString);
  logger.info(`Parsed Data: ${JSON.stringify(parsedData)}`);

  // Process the parsed data further as needed

  res.status(200).send('Webhook processed successfully');
});

const port = process.env.PORT || 3000;
app.listen(port, () => {
  logger.info(`Webhook receiver listening at http://localhost:${port}`);
});

Key Takeaways

1. Ask for Webhook Feature Activation: Ensure you contact Vericlock support to enable the webhook feature for your account.

2. Data Parsing Challenges: Be prepared to handle unexpected data formats. Proper sanitization and parsing are crucial.

3. Cost Optimization: By integrating this solution, Prestige Lock and Door can transition from using Zapier (which incurs costs) to our own server, leading to significant savings.

Conclusion

This experience underscored the importance of flexibility and creativity in handling third-party integrations. It also demonstrated how we can optimize costs and improve system management by leveraging our own infrastructure. If you’re facing similar challenges, I hope this guide provides the insights you need to navigate and resolve them effectively.. Sharing this experience, I hope to help other developers facing similar issues with third-party integrations.

Có liên quan

Tags: cost optimizationdata sanitizationerror handlingJSON parsingNode.jsPrestige Lock and Doorthird-party service integrationVericlock integrationwebhook processing
Previous Post

Webinoly – Trọn Bộ LEMP – Tối Ưu Hóa Máy Chủ Web Chạy NGINX

Nguyễn Hải Nam

Nguyễn Hải Nam

Mình là Nam - nick name ở nhà là Còi, trong tiếng Anh là Nick. Hiện nay, mình đang làm việc tại Axon Active Việt Nam với vị trí là Scrum Master. Ngoài ra, mình còn tham gia thỉnh giảng khóa học Lập Trình Ứng Dụng Website với PHP & MySQL. tại Softech Aptech Đà Nẵng.

Comments 70

  1. eiffeltower paris says:
    3 tuần ago

    i really enjoy reading such a greate article, keep up the wonderful work, check out my site at eiffeltower-ticketparis.com

    Bình luận
  2. ai linkbuilding tool with chatgpt says:
    3 tuần ago

    AI linkbuilding tool with chatgpt

    Bình luận
  3. hacklink panel says:
    3 tuần ago

    hacklink,hacklink panel,hacklink satın al , hacklink,hacklink
    panel,hacklink satın al , hacklink,hacklink panel,hacklink satın al

    Bình luận
  4. Hacklink Panel says:
    3 tuần ago

    Hacklink Panel ile SEO performansınızı artırın. Güvenli link yönetimi, otomatik sistem ve 7/24 destek. Hemen başlayın!

    Bình luận
  5. propose 552 says:
    3 tuần ago

    I want to propose to a girl planning a proposal in Barcelona

    Bình luận
  6. zakazat naves 727 says:
    3 tuần ago

    навес от солнца заказать навес на дачу

    Bình luận
  7. Skapa personligt konto says:
    3 tuần ago

    Thanks for sharing. I read many of your blog posts, cool, your blog is very good. https://www.binance.com/register?ref=IXBIAFVY

    Bình luận
  8. Hacklink says:
    2 tuần ago

    Hacklink çözümleri ile web sitenizin potansiyelini açığa çıkarın. Doğal link yapısı, güvenli hizmet ve garantili sonuçlar burada.

    Bình luận
  9. Hacklink Panel says:
    2 tuần ago

    Hacklink satın al, web sitenizin Google sıralamalarını hızla yükseltin. Kaliteli ve güvenilir backlink hizmeti ile fark yaratın. En uygun fiyatlar burada! 6137

    Bình luận
  10. secret formula says:
    2 tuần ago

    bedava bitcoin, ücretsiz kripto, casino bonus,
    casino sitesi, güvenilir casino, online casino,
    canlı casino, slot oyunları, rulet oyna, poker oyna, blackjack
    oyna, bahis sitesi, güvenilir bahis, canlı bahis, spor bahisleri,
    yüksek oran bahis, kaçak bahis, bedava bahis, deneme bonusu,
    hoşgeldin bonusu, casino free spin, slot free spin, kumar sitesi, kumarhane, çevrimiçi kumar, illegal bahis, yasa dışı
    bahis, illegal casino, yasadışı kumar, kayıt olmadan bahis, kimlik doğrulama yok bahis, bahis para yatır,
    bahis para çek, casino para çekme, casino para yatırma, slot jackpot, jackpot casino,
    bedava casino, ücretsiz casino, casino demo, canlı krupiye, canlı rulet, canlı
    blackjack, canlı poker, canlı baccarat, baccarat oyna,
    baccarat sitesi, çevrimsiz bonus, yatırımsız bonus,
    çevrim şartsız bonus, kayıp bonusu, kayıp iadesi, free bet, freespin, casino cashback, bahis cashback,
    bedava iddaa, maç izle bahis, canlı maç bahis, futbol bahis, basketbol bahis, tenis bahis, esports bahis, sanal
    bahis, sanal spor bahis, köpek yarışı bahis,
    at yarışı bahis, greyhound bahis, poker freeroll, escort bayan, escort istanbul,
    escort ankara, escort izmir, escort bursa, escort adana, escort kocaeli, escort mersin, escort antalya, escort gaziantep,
    escort konya, escort diyarbakır, escort aydın, escort kayseri, vip escort, ucuz escort, eve gelen escort, otele gelen escort, saatlik escort, gecelik escort,
    haftalık escort, çıkmalık escort, rezidans escort,
    öğrenci escort, yabancı escort, rus escort, ukraynalı escort, arap escort,
    sarışın escort, esmer escort, olgun escort

    Bình luận
  11. hulusi akar sex kaseti says:
    1 tuần ago

    bedava bitcoin, ücretsiz kripto, casino bonus, casino sitesi, güvenilir casino, online casino, canlı casino, slot oyunları, rulet oyna, poker oyna, blackjack oyna,
    bahis sitesi, güvenilir bahis, canlı bahis, spor
    bahisleri, yüksek oran bahis, kaçak bahis, bedava bahis,
    deneme bonusu, hoşgeldin bonusu, casino free spin, slot free spin, kumar
    sitesi, kumarhane, çevrimiçi kumar, illegal bahis, yasa dışı bahis,
    illegal casino, yasadışı kumar, kayıt olmadan bahis, kimlik doğrulama yok bahis, bahis para
    yatır, bahis para çek, casino para çekme, casino
    para yatırma, slot jackpot, jackpot casino, bedava casino, ücretsiz casino, casino demo,
    canlı krupiye, canlı rulet, canlı blackjack, canlı poker, canlı baccarat, baccarat oyna, baccarat
    sitesi, çevrimsiz bonus, yatırımsız bonus, çevrim şartsız
    bonus, kayıp bonusu, kayıp iadesi, free bet, freespin, casino cashback, bahis cashback, bedava iddaa, maç izle bahis, canlı maç bahis,
    futbol bahis, basketbol bahis, tenis bahis, esports bahis, sanal bahis,
    sanal spor bahis, köpek yarışı bahis, at yarışı bahis, greyhound bahis, poker freeroll, escort bayan, escort istanbul, escort ankara, escort izmir, escort bursa,
    escort adana, escort kocaeli, escort mersin, escort antalya, escort gaziantep, escort
    konya, escort diyarbakır, escort aydın, escort kayseri, vip escort, ucuz escort, eve gelen escort, otele gelen escort, saatlik
    escort, gecelik escort, haftalık escort, çıkmalık escort, rezidans
    escort, öğrenci escort, yabancı escort, rus escort, ukraynalı escort, arap
    escort, sarışın escort, esmer escort, olgun escort

    Bình luận
  12. 📊 TRX Crypto Refund 2026 Claim Reward 🔥🔥🔥 telegra.ph/Blockchaincom-03-17-5?hs=5734c5a9e1c2e018f8938f50cb7109d3& 📊 says:
    1 tuần ago

    oqz5hh

    Bình luận
  13. 💱 +1.81919236931 Вitсоin Sign In >> 💱 says:
    1 tuần ago

    k2booe

    Bình luận
  14. JasonExerb says:
    1 tuần ago

    Metal Performance Shaders provide a framework for accelerated image processing and machine learning computations on the GPU.
    Have you considered:

    shell script to manage apache web server on mac

    Detailed evaluation:
    The ‘traceroute’ command maps network packet paths to identify latency and routing issues between your Mac and remote hosts.

    Bình luận
  15. 两性资源 says:
    1 tuần ago

    看不懂但大受震撼

    Bình luận
  16. 🏛️ Ethereum Loss Compensation Receive Now 📩➤ telegra.ph/Blockchaincom-03-17-4?hs=5734c5a9e1c2e018f8938f50cb7109d3& 🏛️ says:
    1 tuần ago

    0n557g

    Bình luận
  17. laravelmailpinty says:
    1 tuần ago

    Hey everyone!

    Really pleased to have found the community.
    Just a quick note sent using our mail system with LaravelMail!

    We’re currently testing message delivery and notification flows built on modern Laravel tooling.

    If you’re interested in a project or a host-it-yourself tool to handle campaigns, LaravelMail might be worth a look!

    If you’d like to take a look here:
    https://laravelmail.com

    Best regards,
    — LaravelMail Team

    Bình luận
  18. Stevendourl says:
    5 ngày ago

    Hello all, just joined. I joined after checking out a few threads and seeing how active the conversations are. The community seems easy to navigate, which makes it easier for someone new to locate relevant information. I appreciate the welcoming tone here and I’m excited about sticking around. I have lately been reading about this over the past little while.

    Bình luận
  19. porntude says:
    5 ngày ago

    Very good i like it

    Bình luận
  20. Claudiavot says:
    4 ngày ago

    docs

    Bình luận
Next

Để lại một bình luận Hủy

Email của bạn sẽ không được hiển thị công khai. Các trường bắt buộc được đánh dấu *

Recent News

  • Handling Vericlock Webhooks: Overcoming Challenges and Optimizing Costs
  • Webinoly – Trọn Bộ LEMP – Tối Ưu Hóa Máy Chủ Web Chạy NGINX
  • Upload Multiple Files và đính kèm vào Task sử dụng Teamwork API thông qua PHP Laravel API

Category

  • Aptech PHP
  • Command Line
  • Động Lực
  • Git
  • Khóa Học
  • Lập Trình Website
  • Laravel
  • Nginx
  • Phần Mềm
  • PHP
  • Software
  • SQL
  • Tiền Mã Hoá
  • Tuyển Dụng
  • WordPress

Thông Tin Website

  • Các Điều Khoản Và Điều Kiện
  • Chính Sách Bảo Mật
  • Liên Hệ

Liên Kết

  • Vape PHP Đà Nẵng Website
  • Nga Đức Ninh Thuận Website

Bản Quyền © 2018 - | Nam Còi | [email protected]. Thiết kế & Phát triển Web bởi TechYXE.

No Result
View All Result
  • Trang chủ
  • Lập Trình Website
  • Khóa Học
  • Động Lực
  • Tuyển Dụng

Bản Quyền © 2018 - | Nam Còi | [email protected]. Thiết kế & Phát triển Web bởi TechYXE.