# 500 Internal error when importing SP config

**URL:** <https://developer.sailpoint.com/discuss/t/500-internal-error-when-importing-sp-config/6183>\
**Category:** SHF Discussion and Questions\
**Tags:** apis\
**Created:** [October 11, 2022, 10:44am UTC](https://developer.sailpoint.com/discuss/t/500-internal-error-when-importing-sp-config/6183 "2022-10-11T10:44:51Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![Beatriz](https://avatars.discourse-cdn.com/v4/letter/b/f9ae1b/32.png) [@Beatriz](https://developer.sailpoint.com/discuss/u/Beatriz)\
**Post date:** [October 11, 2022, 10:44am UTC](https://developer.sailpoint.com/discuss/t/500-internal-error-when-importing-sp-config/6183/1 "2022-10-11T10:44:51Z")

</div>

Hello Experts,

We are trying to use the SP config API methods to export/import objects to new IdentityNow environments. We are able to do it using postman but when we use a python script it doesn’t matter how we send the json file we always get a

```auto
{
  "messages": [
    {
      "locale": "en-US",
      "text": "An internal fault occurred.",
      "localeOrigin": "REQUEST"
    },
    {
      "locale": "en-US",
      "text": "An internal fault occurred.",
      "localeOrigin": "DEFAULT"
    }
  ],
  "detailCode": "500.0 Internal fault",
  "trackingId": "23f069582f30483b9d4f61887a88bbdf"
}

```

The request we are doing is:

```auto

headers = {
  'Content-Type': 'multipart/form-data',
  'Accept': 'application/json',
  'Authorization': 'Bearer ' + tokenSB['access_token']
}

```

```auto
payload={'data': ('exportimportResult.json',open('exportimportResult.json'))}

```

```auto
response2 = requests.request("POST", importConfigURL, headers=headers, verify=False, files=payload)

```

Based on the documentation, we are sending the json file as expected ([sp-config-import | SailPoint Developer Community](https://developer.sailpoint.com/idn/api/beta/sp-config-import)).

Please, have anyone face the same issue? any idea about what’s the root of the error?

Regards,  
Beatriz.

---

<div class="post-metadata">

**Author:** ![colin\_mckibben](https://sea1.discourse-cdn.com/sailpoint/discuss/user_avatar/developer.sailpoint.com/colin_mckibben/32/37182_2.png) [@colin\_mckibben](https://developer.sailpoint.com/discuss/u/colin_mckibben)\
**Post date:** [October 11, 2022, 2:57pm UTC](https://developer.sailpoint.com/discuss/t/500-internal-error-when-importing-sp-config/6183/2 "2022-10-11T14:57:09Z")

</div>

The example python code given in the API spec doesn’t appear to be correct for a multipart/form-data upload. Here is the code I generated from Postman.

```python
import requests

url = "https://<tenant>.api.identitynow.com/beta/sp-config/import"

payload={}
files=[
  ('data',('export.json',open('export.json','rb'),'application/json'))
]
headers = {
  'Authorization': 'Bearer <token>'
}

response = requests.request("POST", url, headers=headers, data=payload, files=files)

print(response.text)

```

I have [submitted an issue](https://github.com/sailpoint-oss/developer.sailpoint.com/issues/80) to fix the spec example.

---

<div class="post-metadata">

**Author:** ![sam\_jung](https://avatars.discourse-cdn.com/v4/letter/s/919ad9/32.png) [@sam\_jung](https://developer.sailpoint.com/discuss/u/sam_jung)\
**Post date:** [February 6, 2023, 6:26pm UTC](https://developer.sailpoint.com/discuss/t/500-internal-error-when-importing-sp-config/6183/3 "2023-02-06T18:26:53Z")

</div>

We are trying to do that now and experiencing the same error. Is there a work around for this at this time?

---

<div class="post-metadata">

**Author:** ![Beatriz](https://avatars.discourse-cdn.com/v4/letter/b/f9ae1b/32.png) [@Beatriz](https://developer.sailpoint.com/discuss/u/Beatriz)\
**Post date:** [February 6, 2023, 8:17pm UTC](https://developer.sailpoint.com/discuss/t/500-internal-error-when-importing-sp-config/6183/4 "2023-02-06T20:17:37Z")

</div>

Yes, try this:

> importConfigURL = baseUrl+“/beta/sp-config/import?preview=false”
> 
> with open(‘exportimportResult.json’, ‘w’, encoding=‘utf-8’) as my\_file:  
> my\_file.write(json.dumps(exportimportResult))
> 
> files=[  
> (‘data’,(‘export.json’,open(‘exportimportResult.json’,‘rb’),‘application/json’))  
> ]
> 
> headers = {  
> ‘Authorization’: 'Bearer ’ + token[‘access\_token’]  
> }
> 
> response = requests.request(“POST”, importConfigURL, headers=headers, verify=False, files=files)

Cheers!

---

<div class="post-metadata">

**Author:** ![system](https://global.discourse-cdn.com/sailpoint/original/2X/f/f2136700ed5e3703e0b85e02f6be799dacca7735.png) [@system](https://developer.sailpoint.com/discuss/u/system)\
**Post date:** [July 19, 2023, 2:23pm UTC](https://developer.sailpoint.com/discuss/t/500-internal-error-when-importing-sp-config/6183/5 "2023-07-19T14:23:41Z")

</div>


