Creating a credit note via api Call

Hi Team,

I am in need of creation of CREDIT NOTE vai API call on cancellation of my invoices.
In order to achieve this functionality, I followed the link as follows

Unfortunately, I am getting error, could you please help me with right steps to achieve the same.
Please suggest me right API and corresponding request string.

API:- https://api.quickfile.co.uk/1_2/invoice/create

Request String:-

{
  "payload": {
    "Header": {
      "MessageType": "Request",
      "SubmissionNumber": "EPTESTINGCREDITNOTE",
      "Authentication": {
        "AccNumber": "XXXXXXXXXXX",
        "MD5Value": "XXXXXXXXXXXXXXXXXXXXXX",
        "ApplicationID": "XXXXXXXXXXXXXXXXXXXXXXXXXXXX"
      }
    },
    "Body": {
      "InvoiceData": {
        "InvoiceType": "INVOICE",
        "ClientID": "XXXXXXX",
        "ClientAddress": {
          "Address": "123 Test Street<br/>Manchester<br/>MA1 5TH<br/>United Kingdom",
          "CountryISO": "GB"
        },
        "Currency": "GBP",
        "TermDays": "14",
        "Language": "en",
        "InvoiceLines": {
          "ItemLines": {
            "ItemLine": [
              {
                "ItemID": "0",
                "ItemName": "EMB1",
                "ItemDescription": "Embossing Stamp",
                "ItemNominalCode": "4000",
                "Tax1": {
                  "TaxName": "VAT",
                  "TaxPercentage": "00.00",
                  "TaxAmount": "00"
                },
                "UnitCost": "-276.74",
                "Qty": "1"
              }
            ]
          }
        },
        "Scheduling": {
          "SingleInvoiceData": {
            "IssueDate": "2017-05-23"
          }
        }
		},
        "CreditNote": {
          "CreditNoteType": "VOID",
          "ParentInvoiceID": "12050783"
        }
    }
  }
}

One thing that jumps out at me immediately is that you can’t have line breaks within a JSON string literal. I would very very strongly recommend using a proper JSON serialization library to send your requests rather than trying to construct the JSON by hand with string manipulation, but for quick testing you can probably get away with replacing the line breaks within the address with \n, i.e.

"Address": "123 Test Street\nManchester\nMA1 5TH\nUnited Kingdom"

A proper serializer will handle this (and the other requirements of the JSON format like escaping of nested quotes) for you.

Also, when you want to post blocks of JSON code like this on the forum, there’s a Markdown trick to make it much more readable - put three backticks before and after the content:

```
{ ... }
```

This then preserves any indentation, and stops it replacing normal " quotes with “curly quotes”.

1 Like

Hi @Aashish

I’ve amended your post to format the JSON correctly (like @ian_roberts mentioned above).

Can you let us know the error you’re seeing please?

Ah, ok, with @QFMathew’s formatting fix I see my original suggestion is irrelevant. Exactly what error message are you receiving? That 2017 IssueDate may be a problem, if you’ve run your year end and already locked that period.

Thanks team for your quick suggestion, Its fixed now.
In addition would like to know when ETA for purchase ledger to be implemented in this API.

Thanks
Aashish

This topic was automatically closed after 7 days. New replies are no longer allowed.