NetTalk Central

Author Topic: Inbound stream from Postmark  (Read 2378 times)

JohanR

  • Sr. Member
  • ****
  • Posts: 375
    • View Profile
    • Email
Inbound stream from Postmark
« on: March 30, 2024, 03:38:44 AM »
Hi,

I have created my NetWebPage to receive data (JSON) from Postmark,
as well as the data structures and code using the CodeWriter

but am a little confused as to how to get the data to load into the json data structure?
p_web.?

p_web.GetValue('json') , gives me nothing,
do I need to set some settings first, or which p_web method do I use to return the data to load into

  SomeLoadString.SetValue(p_web.GetValue('json'))
  json.start()
  json.SetTagCase(jf:CaseAsIs)
  json.Load(element,SomeLoadString) ! Load From a StringTheory object


This seems to give me an empty string


thanks

Johan






JohanR

  • Sr. Member
  • ****
  • Posts: 375
    • View Profile
    • Email
Re: Inbound stream from Postmark
« Reply #1 on: March 30, 2024, 04:03:06 AM »
Hi,

Forgot to add,
the ContentType is set to application/json 

[st][3] [netTalk][thread=3] TVCWEB - p_web.RequestContentType:application/json
[st][3] [netTalk][thread=3] TVCWEB - p_web._UserAgent:postmark

below the post data from the server window

POST /ReceiveStatements HTTP/1.1
Host: www.vineyardconnection.co.za
X-PM-Webhook-Trace-Id: c2d5bcbc-1eff-4695-bfe9-c2be112ce564
X-PM-Webhook-Event-Id: test-hook
X-PM-Retries-Remaining: 0
Expect: 100-continue
Connection: close
User-Agent: Postmark
Content-Type: application/json
Content-Length: 1702

{
  "Date": "Sat, 30 Mar 2024 11:35:48 +0000",
  "From": "support@postmarkapp.com",
  "FromName": "Postmarkapp Support",
  "FromFull": {
    "Email": "support@postmarkapp.com",
    "MailboxHash": "",
    "Name": "Postmarkapp Support"
  },
  "HtmlBody": "<html><body><p>This is a test html body.</p></body></html>",
  "MailboxHash": "SampleHash",
  "MessageID": "00000000-0000-0000-0000-000000000000",
  "MessageStream": "inbound",
  "ReplyTo": "replyto@example.com",
  "Subject": "Test subject",
  "Tag": "TestTag",
  "TextBody": "This is a test text body.",
  "Headers": [
    {
      "Name": "X-Header-Test",
      "Value": ""
    }
  ],
  "To": "\"Firstname Lastname\" <mailbox+SampleHash@inbound.postmarkapp.com>",
  "ToFull": [
    {
      "Email": "mailbox+SampleHash@inbound.postmarkapp.com",
      "MailboxHash": "SampleHash",
      "Name": "Firstname Lastname"
    }
  ],
  "Cc": "\"First Cc\" <firstcc@postmarkapp.com>, secondCc@postmarkapp.com",
  "CcFull": [
    {
      "Email": "firstcc@postmarkapp.com",
      "MailboxHash": "",
      "Name": "First Cc"
    },
    {
      "Email": "secondCc@postmarkapp.com",
      "MailboxHash": "",
      "Name": ""
    }
  ],
  "Bcc": "\"First Bcc\" <firstbcc@postmarkapp.com>",
  "BccFull": [
    {
      "Email": "firstbcc@postmarkapp.com",
      "MailboxHash": "",
      "Name": "First Bcc"
    }
  ],
  "StrippedTextReply": "This is the reply text",
  "OriginalRecipient": "mailbox+SampleHash@inbound.postmarkapp.com",
  "Attachments": [
    {
      "Name": "test.txt",
      "Content": "VGhpcyBpcyBhdHRhY2htZW50IGNvbnRlbnRzLCBiYXNlLTY0IGVuY29kZWQu",
      "ContentLength": 45,
      "ContentType": "text/plain",
      "ContentID": ""
    }
  ]
}


Johan



JohanR

  • Sr. Member
  • ****
  • Posts: 375
    • View Profile
    • Email
Re: Inbound stream from Postmark - Solved
« Reply #2 on: March 31, 2024, 03:43:54 AM »
Hi,

 p_web.RequestData.DataStringtheory
contains the post data in a stringtheory obect

NetWebServerRequestDataType           group,type
WebServer                               &NetWebServer       ! Pointer back to our Web Server object
FromIP                                  like (Net:SimplePacketType.FromIP)
OnSocket                                like (Net:SimplePacketType.OnSocket)
SockID                                  like (Net:SimplePacketType.SockID)
DataStringTheory                        &StringTheory
RequestMethodType                       long                ! e.g. NetWebServer_POST or NetWebServer_GET
SiteId                                  long
SessionId                               String(Net:MaxSessionLength)                ! used when deleting sessions
                                      end



 Assign from stringtheory to stringtheory object

 SomeLoadString.SetValue(p_web.RequestData.DataStringtheory)

really cool and easy once you get the how and what to use

Johan