NetTalk Central

Author Topic: NetWebClient POST  (Read 1105 times)

wasatchconsulting

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
    • Email
NetWebClient POST
« on: February 21, 2023, 06:06:19 PM »
I am working on an interface with an API and have run into a road block.

The API that I am accessing gives examples using Postman. When setting it up in Postman it works great, but it is not working in the WebClient demo.

In Postman you enter the "values" being sent in the "Header" tab. I tried placing these into the net.CustomHeader and net.SetValue, but it will not work. I also placed the json string into the post data with no luck.

I am looking for direction on translating from Postman Headers to NetTalk 12.

Thanks
Ken Watts
Wasatch Consulting Services

Bruce

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 11171
    • View Profile
Re: NetWebClient POST
« Reply #1 on: February 21, 2023, 09:39:35 PM »
Hi Ken,

you need to be more specific on what values you are adding to the header (in postman) and how you translated this into your clarion code to setting net.customheader.

CustomHeader is the correct property, I'm guessing you set it wrong, but without specifics I can't be sure.

Cheers
Bruce

wasatchconsulting

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
    • Email
Re: NetWebClient POST
« Reply #2 on: February 22, 2023, 10:53:01 AM »
Here is the code I have tried:

NetItemImport.SetAllHeadersDefault()
NetItemImport.CustomHeader = 'Authorization: Bearer '&CLIP(GLO:AccessToken)
NetItemImport.CustomHeader = 'Accept: application/json'
GLO:URL = 'https://api.lightspeedapp.com/API/V3/Account/'&CLIP(GLO:AccountID)&'/Item.json'
NetItemImport.ContentType = 'application/json'
NetItemImport.Accept_ = 'application/json'
NetItemImport.Post(GLO:URL)

I have attached an image of the Postman setup as well.

Ken Watts

wasatchconsulting

  • Jr. Member
  • **
  • Posts: 71
    • View Profile
    • Email
Re: NetWebClient POST
« Reply #3 on: February 23, 2023, 01:31:53 PM »
Bruce,

I found my mistake and getting the correct response now.

Thanks
Ken Watts