Skip to main content

Notifications

Dynamics 365 Community / Forums / Field Service forum / creating purchase invo...
Field Service forum

creating purchase invoice with API issue

Posted on by Microsoft Employee

I am trying to create an integration for one of my product.

I am trying to create a purchase invoice object But it is not working. When I try to create it, I always see an error.

{
    "error": {
        "code": "BadRequest",
        "message": "Invalid Request Body"
    }
}


Here it is how i am trying it,

I am using it with postman Basic Auth.

My companies, I am using demo company to do some work with api

GET https://api.businesscentral.dynamics.com/v1.0/f423b8ee-9865-46b0-89ca-51306d13723e/api/beta/companies

{
    "@odata.context": "api.businesscentral.dynamics.com/.../beta$metadata#companies",
    "value": [
        {
            "id": "0d5c1b40-566e-4f66-8b1f-f2565999aaa6",
            "systemVersion": "24630",
            "name": "CRONUS USA, Inc.",
            "displayName": "CRONUS USA, Inc.",
            "businessProfileId": ""
        },
        {
            "id": "d5884aca-8631-4e18-a0b3-ab3f41fe953f",
            "systemVersion": "24630",
            "name": "My Company",
            "displayName": "Roger Test, Inc.",
            "businessProfileId": ""
        }
    ]
}

Here is how I am creating vendor

POST api.businesscentral.dynamics.com/.../vendors

{
  "number": "40001",
  "displayName": "Wide World Importers CRONUS",
  "phoneNumber": "",
  "email": "toby.rhodee@cronuscorp.net",
  "website": "",
  "taxRegistrationNumber": "",
  "currencyCode": "USD",
  "taxLiable": true
}

Response
{
    "@odata.context": "api.businesscentral.dynamics.com/.../beta$metadata#companies(0d5c1b40-566e-4f66-8b1f-f2565999aaa6)/vendors/$entity",
    "@odata.etag": "W/\"JzQ0O2JkZmxVL21XNG9YdHJ4Q1R6MERQWnFGdEdHUmhqNWZhT0o2NjZSbDZvY3M9MTswMDsn\"",
    "id": "5ca97734-062f-4c45-8b90-5308a5d02ee7",
    "number": "40001",
    "displayName": "Wide World Importers CRONUS",
    "phoneNumber": "",
    "email": "toby.rhodee@cronuscorp.net",
    "website": "",
    "taxRegistrationNumber": "",
    "currencyId": "00000000-0000-0000-0000-000000000000",
    "currencyCode": "USD",
    "irs1099Code": "",
    "paymentTermsId": "1fc4d374-dc47-4111-8a01-a2177c88ceb3",
    "paymentMethodId": "f9381827-f136-4a27-bb33-52254841129d",
    "taxLiable": true,
    "blocked": " ",
    "balance": 0,
    "lastModifiedDateTime": "2018-10-22T08:39:09.443Z",
    "address": {
        "street": "",
        "city": "",
        "state": "",
        "countryLetterCode": "",
        "postalCode": ""
    }
}

Here is how i am trying to creating purchase invoice

POST api.businesscentral.dynamics.com/.../purchaseInvoices

{
  "number": "108736",
  "invoiceDate": "2018-09-25",
  "vendorNumber": "20002",
  "currencyCode": "EUR",
  "paymentTerms": "COD",
  "shipmentMethod": "CFR"
}


But after this request , i always see an error, BAd request, Invalid Request Body. 
Can you please point out, what can be issue?

Categories:
  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: creating purchase invoice with API issue
    Please read purchase invoice object as it is below, beacuse i am unable to edit my own post. so can not make correction in original post
    
    POST api.businesscentral.dynamics.com/.../purchaseInvoices
    
    {
      "number": "108736",
      "invoiceDate": "2018-09-25",
      "vendorNumber": "40001",
      "currencyCode": "EUR",
      "paymentTerms": "COD",
      "shipmentMethod": "CFR"
    }

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

November Spotlight Star - Khushbu Rajvi

Congratulations to a top community star!

Forum Structure Changes Coming on 11/8!

In our never-ending quest to help the Dynamics 365 Community members get answers faster …

Dynamics 365 Community Platform update – Oct 28

Welcome to the next edition of the Community Platform Update. This is a status …

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 290,867 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 229,173 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans