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


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.


1 Like

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


1 Like

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


@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.

1 Like

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 :slight_smile:

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:


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 :wink:

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