Web Connection
How interpret FoxPro object passed to wwprocess method
Gravatar is a globally recognized avatar based on your email address. How interpret FoxPro object passed to wwprocess method
  VFPJCOOK
  All
  Apr 12, 2024 @ 10:59am

I have a REST API developed using WWWC. It has a process method name InmatePostCommSale() I have a website that is calling this API endpoint with the following JSON:

POST http://localhost/ITFBO/InmatePostCommSale.ip HTTP/2.0
Accept-Encoding: gzip,deflate
Content-Type: application/json

{
  "purchase": {
    "citf": "LPSO",
    "citfuserid": "2314734",
    "citfsessiontoken": "A6BBB754BD9F4EB9",
    "citfdob": "",
    "citfpassword": "",
    "citfs1ans": "",
    "citfs2ans": "",
    "citfs3ans": ""
  },
  "lineitems": [
    {
      "cpl_dscs_id": "0142C45AFF0A4C89",
      "nqty": 8,
      "yunit_price": 1.35,
      "ntax_rate": 8.45
    },
    {
      "cpl_dscs_id": "034CA60B26FD4C8A",
      "nqty": 1,
      "yunit_price": 32.89,
      "ntax_rate": 8.45
    },
    {
      "cpl_dscs_id": "03605BACB1364791",
      "nqty": 5,
      "yunit_price": 3.32,
      "ntax_rate": 8.45
    },
    {
      "cpl_dscs_id": "037FB5C58F8849B2",
      "nqty": 3,
      "yunit_price": 6.04,
      "ntax_rate": 4
    },
    {
      "cpl_dscs_id": "0B81210989A649AC",
      "nqty": 1,
      "yunit_price": 4.03,
      "ntax_rate": 4
    }
  ]
}

I am in the InmatePostCommSale method. so my code looks like this:

FUNCTION InmatePostCommSale(toJSON)

I can extract citf by doing this: lcitf = toJSON.purchase.citf I know that lcitf contains "LPSO" What I do not understand is how do I take the lineitems and put them into a curor or array or just iterate thru them.

Thanks, John

Gravatar is a globally recognized avatar based on your email address. re: How interpret FoxPro object passed to wwprocess method
  VFPJCOOK
  Rick Strahl
  Apr 12, 2024 @ 12:29pm

Hi Rick, Thanks.

I tried this but am getting in wcerrors.txt:

2024-04-12 18:20:03.771 - 280285252001_7 - Com Server Execution Error: itfboprocess.getendpointparamsb c:\webconnectionprojects\itfbo\deploy\itfboprocess.prg Error in line 1149 Variable 'LCLINEITEMSCURSOR' is not found. 12 - /itfbo/inmatepostcommsale.ip 2024-04-12 18:20:03.776 - 280285252001_7 - No output returned - /itfbo/inmatepostcommsale.ip

Line 1149 is the CollectionToCursor line.

My code:

   lcitf = topassedJSON.purchase.citf
   lcitfuserid = topassedJSON.purchase.citfuserid
   lcitfsessiontoken = topassedJSON.purchase.citfsessiontoken
   CREATE CURSOR lclineitemscursor (cpl_dscs_id c(16),nqty n(6,0),yunit_price Y,ntax_rate n(8,4))
   collectiontocursor(topassedJSON,lclineitemscursor,"lineitems")

Is there something I am missing?

Thanks

Gravatar is a globally recognized avatar based on your email address. re: How interpret FoxPro object passed to wwprocess method
  Rick Strahl
  VFPJCOOK
  Apr 12, 2024 @ 08:02pm

The problem is your SQL statement.

And what are you doing debugging your code in COM?

+++ Rick ---

© 1996-2024