# API calls to add new Distributions - some fields won't work

**URL:** <https://community.aristotlemetadata.com/t/api-calls-to-add-new-distributions-some-fields-wont-work/131>\
**Category:** API & Programming\
**Created:** [June 28, 2021, 3:50am UTC](https://community.aristotlemetadata.com/t/api-calls-to-add-new-distributions-some-fields-wont-work/131 "2021-06-28T03:50:04Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Michael](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.aristotlemetadata.com/michael/32/188_2.png) [@Michael](https://community.aristotlemetadata.com/u/Michael)\
**Post date:** [June 28, 2021, 3:50am UTC](https://community.aristotlemetadata.com/t/api-calls-to-add-new-distributions-some-fields-wont-work/131/1 "2021-06-28T03:50:05Z")

</div>

Hello,

I’ve used the API (/metadata/distribution) to create a new distribution, however I can’t seem to get any records added to either:

- distributiondataelementpath\_set
- customvalue\_set

The calls I’m making seem to work, however any additional fields within distributiondataelementpath\_set or customvalue\_set are ignored.

I’ve also tried using update (​/metadata​/distribution​/{item\_id}) to add these via a second call, but again no luck.

Here’s a sample bit of json I’d pass to the API to process. Everything loads fine, except distributiondataelementpath\_set or customvalue\_set. Appreciate any insight as to what I’m doing wrong.

![image](https://canada1.discourse-cdn.com/flex029/uploads/aristotle/original/1X/6a00b7c50460ffe0d7cab6f4c8fce3e6027a155f.png)

---

<div class="post-metadata">

**Author:** ![silke](https://avatars.discourse-cdn.com/v4/letter/s/a5b964/32.png) [@silke](https://community.aristotlemetadata.com/u/silke)\
**Post date:** [June 28, 2021, 3:56am UTC](https://community.aristotlemetadata.com/t/api-calls-to-add-new-distributions-some-fields-wont-work/131/2 "2021-06-28T03:56:58Z")

</div>

Hi @Michael, just letting you know that I’m investigating this. I should have more details shortly.

Cheers

---

<div class="post-metadata">

**Author:** ![silke](https://avatars.discourse-cdn.com/v4/letter/s/a5b964/32.png) [@silke](https://community.aristotlemetadata.com/u/silke)\
**Post date:** [June 28, 2021, 5:14am UTC](https://community.aristotlemetadata.com/t/api-calls-to-add-new-distributions-some-fields-wont-work/131/4 "2021-06-28T05:14:40Z")

</div>

@Michael, I’ve sent you an email to get some followup details

Cheers

---

<div class="post-metadata">

**Author:** ![Michael](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.aristotlemetadata.com/michael/32/188_2.png) [@Michael](https://community.aristotlemetadata.com/u/Michael)\
**Post date:** [June 28, 2021, 6:28am UTC](https://community.aristotlemetadata.com/t/api-calls-to-add-new-distributions-some-fields-wont-work/131/5 "2021-06-28T06:28:39Z")

</div>

@silke Yes it looks like the JSON is largely good, but I’m guessing the error comes from the Python interpretation of the JSON when dealing with arrays of values.

Thanks for the help, I’ll dig a little deeper.

---

<div class="post-metadata">

**Author:** ![Michael](https://yyz1.discourse-cdn.com/flex029/user_avatar/community.aristotlemetadata.com/michael/32/188_2.png) [@Michael](https://community.aristotlemetadata.com/u/Michael)\
**Post date:** [June 28, 2021, 11:26pm UTC](https://community.aristotlemetadata.com/t/api-calls-to-add-new-distributions-some-fields-wont-work/131/6 "2021-06-28T23:26:43Z")

</div>

Found the issue. In Python a line like this will partially work… implementing all your simple json but omitting anything more complex and nested a little deeper in. It’s expecting a dictionary, list of tuples… anything except JSON. So distributiondataelementpath\_set and customvalue\_set will indeed fail if you use a line like this:

> ```
> r = requests.post(apiPutUrl, data=jsonMetadata)
> 
> ```

The fact that it _partially_ works is what threw me 🙂

Instead, for json objects, drop data and instead use the json parameter. It needed to be:

> ```
> r = requests.post(apiPutUrl, json=jsonMetadata)
> 
> ```

Also, the source json in customvalue\_set need not specify id at all. Ultimately, to build a bare bones distribution with technical detail only this is the format I went with:

![image](https://canada1.discourse-cdn.com/flex029/uploads/aristotle/original/1X/fc43d63a5eabecc5a953c60793980a5788ed7df4.png)

The whole point of this was to write a routine to preload a bunch of minimalist distributions with technical data only. This will allow for developers to start tying in this technical detail with higher level logical metadata using this as a foundation. Now that I know the bug I can finish off the code, fun times 😉

Thank you all for your sage wisdom and advice, always present and always appreciated.
