Exporting payment via REST API

Hi All,

In my current project I'm writing a code to create a payment batch in Sage300 via REST API.
In order to do that I'm doing a GET to a random payment and then clearing the fields to add the new data.
Is there a way to get a template of the payload? it would make my code way clearer.
by the way if someone has an example of such code that would give me a good reference. 
I'm using apache olingo for the GET methods and regular http libraries for the export.

thanks,
Itamar

  • Read the documentation, you can use Swagger.

  • 0

    On the Sage server where you have Sage installed, open a browser (not IE) and go to http://localhost/Sage300WebApi/v1.0/-/SAMLTD or whichever your database is called, and when it prompts you to login, use your web API login details which must be entered in upper case. This will present you with a screen with a blue button on it for the swagger UI. Click it and you will get all the endpoints and you can query from there. You can see the schema required for POST and PATCH. You don't need all the fields and you don't need every object in the JSON. You'll need to play around with it to see how little you need to create entries. If you can't log in this way, you will need to read the documentation on how to do that. I provided instructions on how you get it configured properly on this post See my verified answer here

  • 0 in reply to Vega
    1. The payment does not have any allocations.

    2. The currency used for the business (BIZ currency) does not match the currency of the customer.

      Request:
      {
          "BatchRecordType": "CA",
          "BatchNumber": 109,
          "BatchDate": "2023-07-21",
          "Description": "prepay",
          "NumberOfEntries": 1,
          "BankCode": "CCB",
          "DefaultBankCurrency": "CAD",
          "ReceiptsAdjustments": [
              {
                  "BatchType": "CA",
                  "BatchNumber": 109,
                  "EntryNumber": 1,
                  "CustomerNumber": "KAPKAN",
                  "ReceiptDateAdjustmentDate": "2023-07-21",
                  "EntryDescription": "1",
                  "EntryReference": "",
                  "BankReceiptAmount": 13500,
                  "CustomerReceiptAmount": 0,
                  "TotalCustomerAmountApplied": 13500,
                  "ReceiptTransactionType": "Receipt",
                  "MatchingDocumentNumber": "",
                  "PaymentCode": "VISA",
                  "PaymentType": "Check",
                  "CustomerUnappliedAmount": 0
              }
          ]
      }

  • 0 in reply to Vega
    1. The payment does not have any allocations.

    2. The currency used for the business (BIZ currency) matches the currency of the customer.

      Request:

      {
      "BatchRecordType": "CA",
      "BatchNumber": 109,
      "BatchDate": "2023-07-21",
      "Description": "prepay",
      "NumberOfEntries": 1,
      "BankCode": "CCB",
      "DefaultBankCurrency": "CAD",
      "ReceiptsAdjustments": [
      {
      "BatchType": "CA",
      "BatchNumber": 109,
      "EntryNumber": 1,
      "CustomerNumber": "PAYMENT",
      "ReceiptDateAdjustmentDate": "2023-07-21",
      "EntryDescription": "1",
      "EntryReference": "",
      "BankReceiptAmount": 20000,
      "CustomerReceiptAmount": 0,
      "TotalCustomerAmountApplied": 20000,
      "ReceiptTransactionType": "Receipt",
      "MatchingDocumentNumber": "",
      "PaymentCode": "VISA",
      "PaymentType": "Check",
      "CustomerUnappliedAmount": 0
      }
      ]
      }

  • 0 in reply to Vega
    1. The payment does not have any allocations.

    2. The currency used for the business (BIZ currency) does not match the currency of the customer.

      Request:

      {
      "BatchRecordType": "CA",
      "BatchNumber": 109,
      "BatchDate": "2023-07-24",
      "Description": "prepay",
      "NumberOfEntries": 1,
      "BankCode": "CCB",
      "DefaultBankCurrency": "CAD",
      "ReceiptsAdjustments": [
      {
      "BatchType": "CA",
      "BatchNumber": 146,
      "EntryNumber": 1,
      "CustomerNumber": "KAPKAN",
      "ReceiptDateAdjustmentDate": "2023-07-24",
      "EntryDescription": "1",
      "EntryReference": "",
      "BankReceiptAmount": 300,
      "CustomerReceiptAmount": 0,
      "TotalCustomerAmountApplied": 300,
      "ReceiptTransactionType": "Prepayment",
      "PaymentCode": "VISA",
      "PaymentType": "Check",
      "CustomerUnappliedAmount": 0,
      "AppliedReceiptsAdjustments": [
      {
      "BatchType": "CA",
      "BatchNumber": 146,
      "EntryNumber": 1,
      "LineNumber": 20,
      "CustomerNumber": "KAPKAN",
      "PaymentNumber": 1,
      "CustomerReceiptAmount": 195.34
      }
      ]
      }
      ]
      }

  • 0 in reply to Vega
    1. The payment does not have any allocations.

    2. The currency used for the business (BIZ currency) matches the currency of the customer.

      Request:

      {
      "BatchRecordType": "CA",
      "BatchNumber": 109,
      "BatchDate": "2023-07-24",
      "Description": "prepay",
      "NumberOfEntries": 1,
      "BankCode": "CCB",
      "DefaultBankCurrency": "CAD",
      "ReceiptsAdjustments": [
      {
      "BatchType": "CA",
      "BatchNumber": 146,
      "EntryNumber": 1,
      "CustomerNumber": "PAYMENT",
      "ReceiptDateAdjustmentDate": "2023-07-24",
      "EntryDescription": "1",
      "EntryReference": "",
      "BankReceiptAmount": 300,
      "CustomerReceiptAmount": 300,
      "TotalCustomerAmountApplied": 300,
      "ReceiptTransactionType": "Prepayment",
      "PaymentCode": "VISA",
      "PaymentType": "Check",
      "CustomerUnappliedAmount": 0,
      "AppliedReceiptsAdjustments": [
      {
      "BatchType": "CA",
      "BatchNumber": 146,
      "EntryNumber": 1,
      "LineNumber": 20,
      "CustomerNumber": "PAYMENT",
      "PaymentNumber": 1,
      "CustomerReceiptAmount": 300
      }
      ]
      }
      ]
      }

  • 0 in reply to Vega
    1. The payment has an allocation to the invoice.

    2. The currency used for the business (BIZ currency) does not match the currency of the customer.

      Request:
      {
      "BatchRecordType": "CA",
      "BatchNumber": 109,
      "BatchDate": "2023-07-21",
      "Description": "prepay",
      "NumberOfEntries": 1,
      "BankCode": "CCB",
      "DefaultBankCurrency": "CAD",
      "ReceiptsAdjustments": [
      {
      "BatchType": "CA",
      "BatchNumber": 109,
      "EntryNumber": 1,
      "CustomerNumber": "KAPKAN",
      "ReceiptDateAdjustmentDate": "2023-07-21",
      "EntryDescription": "1",
      "EntryReference": "",
      "BankReceiptAmount": 187.00,
      "CustomerReceiptAmount": 0,
      "TotalCustomerAmountApplied": 187.00,
      "ReceiptTransactionType": "Prepayment",
      "DocumentType": "DocumentNumber",
      "MatchingDocumentNumber": "IN00000000000000000047",
      "PaymentCode": "VISA",
      "PaymentType": "Check",
      "CustomerUnappliedAmount": 0,
      "AppliedReceiptsAdjustments": [
      {
      "BatchType": "CA",
      "BatchNumber": 109,
      "EntryNumber": 1,
      "LineNumber": 1,
      "CustomerNumber": "KAPKAN",
      "PaymentNumber": 1,
      "PPMatchingDocumentNumber": "IN00000000000000000047",
      "CustomerReceiptAmount": 121.76,
      "PPMatchingDocumentType": "DocumentNumber",
      "ReceiptTransactionType": "Prepayment",
      "UpdateOperation": "Unspecified"
      }
      ]
      }
      ]
      }

  • 0 in reply to Vega
    1. The payment has an allocation to the invoice.

    2. The currency used for the business (BIZ currency) matches the currency of the customer.

      Request:

      {
      "BatchRecordType": "CA",
      "BatchNumber": 109,
      "BatchDate": "2023-07-21",
      "Description": "prepay",
      "NumberOfEntries": 1,
      "BankCode": "CCB",
      "DefaultBankCurrency": "CAD",
      "ReceiptsAdjustments": [
      {
      "BatchType": "CA",
      "BatchNumber": 109,
      "EntryNumber": 1,
      "CustomerNumber": "PAYMENT",
      "ReceiptDateAdjustmentDate": "2023-07-21",
      "EntryDescription": "1",
      "EntryReference": "",
      "BankReceiptAmount": 70000,
      "CustomerReceiptAmount": 70000,
      "TotalCustomerAmountApplied": 70000,
      "ReceiptTransactionType": "Prepayment",
      "DocumentType": "DocumentNumber",
      "MatchingDocumentNumber": "IN00000000000000000046",
      "PaymentCode": "VISA",
      "PaymentType": "Check",
      "CustomerUnappliedAmount": 0,
      "AppliedReceiptsAdjustments": [
      {
      "BatchType": "CA",
      "BatchNumber": 109,
      "EntryNumber": 1,
      "LineNumber": 1,
      "CustomerNumber": "PAYMENT",
      "PaymentNumber": 1,
      "PPMatchingDocumentNumber": "IN00000000000000000046",
      "CustomerReceiptAmount": 70000,
      "PPMatchingDocumentType": "DocumentNumber",
      "ReceiptTransactionType": "Prepayment",
      "UpdateOperation": "Unspecified"
      }
      ]
      }
      ]
      }

  • 0 in reply to Vega

    The Default Template for Payments with allocation to the invoice.
    Type RECEIPT

    Request:

    {
    "BatchRecordType": "CA",
    "BatchNumber": 200,
    "BatchDate": "2020-07-09",
    "Description": "RECEIPT for AR invoice",
    "BankCode": "CCB",
    "DefaultBankCurrency": "CAD",
    "ReceiptsAdjustments": [
    {
    "BatchType": "CA",
    "BatchNumber": 200,
    "EntryNumber": 1,
    "CustomerNumber": "SAGE 300 T1",
    "ReceiptDateAdjustmentDate": "2020-07-09T00:00:00Z",
    "EntryDescription": "",
    "EntryReference": "",
    "BankReceiptAmount": 100,
    "ReceiptTransactionType": "Receipt",
    "PaymentCode": "VISA",
    "PaymentType": "Check",
    "AppliedReceiptsAdjustments": [
    {
    "BatchType": "CA",
    "BatchNumber": 200,
    "EntryNumber": 1,
    "LineNumber": 20,
    "CustomerNumber": "SAGE 300 T1",
    "DocumentNumber": "IN00000000000000000013",
    "PaymentNumber": 1,
    "CustomerReceiptAmount": 100,
    "UpdateOperation": "Unspecified"
    }
    ],
    "ReceiptAdjustmentOptionalField": [],
    "AdvanceCredits": [],
    "UpdateOperation": "Unspecified"
    }
    ],
    "UpdateOperation": "Unspecified"
    }

  • 0 in reply to Vega

    The Default Template how to apply the Credit Memo to Invoice
    Type APPLY DOCUMENT

    Request:

    {
    "BatchRecordType": "CA",
    "BatchNumber": 200,
    "BatchDate": "2023-07-25",
    "Description": "CreditMemo Allocations",
    "BankCode": "CCB",
    "DefaultBankCurrency": "CAD",
    "ReceiptsAdjustments": [
    {
    "BatchType": "CA",
    "BatchNumber": 200,
    "EntryNumber": 1,
    "CustomerNumber": "",
    "ReceiptDateAdjustmentDate": "2023-07-25",
    "EntryDescription": "",
    "EntryReference": "",
    "ReceiptTransactionType": "ApplyDocument",
    "DocumentType": "CreditNote",
    "DocumentNumber": "",
    "AppliedReceiptsAdjustments": [
    {
    "BatchType": "CA",
    "BatchNumber": 200,
    "EntryNumber": 1,
    "LineNumber": 20,
    "CustomerNumber": "PAYMENT",
    "DocumentNumber": "",
    "PaymentNumber": 1,
    "CustomerReceiptAmount": 113,
    "UpdateOperation": "Unspecified"
    }
    ],
    "ReceiptAdjustmentOptionalField": [],
    "AdvanceCredits": [],
    "UpdateOperation": "Unspecified"
    }
    ],
    "UpdateOperation": "Unspecified"
    }