Getting 400 Bad Request back with no error details

Trying to use the API to create a user with this JSON body, and I'm getting a 400 back. Can anyone see what I'm doing wrong here? There are no details in the response body like I've seen in other 400 messages coming back:

{
"name":"API Test Account",
"department":"API Department",
"email":"abc@brighthorizons.com",
"addresses":[
{
"address":"abc@brighthorizons.com",
"mediaType":"EMAIL",
"type":"PRIMARY"
},
{
"address":"(42197)",
"mediaType":"PHONE",
"type":"PRIMARY"
},
{
"address":"+17209222976",
"mediaType":"PHONE",
"type":"WORK2"
}],
"title":"API Title",
"password":"Welcome123!"
}

Can you provide the correlation ID from the response?

5928751c-b06a-49c9-a2a4-538c6567ab98

I've created API-2528 to include the error information in the response.

The error you're getting is because of "type":"PRIMARY" on the addresses. If you change that to any other allowed type, the request should succeed. I'm not sure if that's helpful though since you probably need to be setting it as primary. I'm waiting on some further information to figure out what's causing that and will open a bug for it once it's tracked down, but wanted to let you know of a possible workaround now.

Thanks - I'll look to see how it gets set when someone clicks the Primary radio button. Maybe I can do them all as WORK, and then go back and UPDATE.

Two things:

  1. There's no need to specify the email in the addresses property. The email property already designates the user's primary email.
  2. User extensions should be set by using the extension property on a Contact (the members of the addresses array). However, the Contract object lacks that property. I've created API-2529 to add the extension property. That will be a quick fix, but won't be available until the next API deployment to prod.

So, with the fix for API-2529, this will be valid, correct?

{
"name":"API Test Account",
"department":"API Department",
"email":"abc@brighthorizons.com",
"addresses":[
{
"extension":"42197",
"mediaType":"PHONE",
"type":"PRIMARY"
},
{
"address":"+17209222976",
"mediaType":"PHONE",
"type":"WORK2"
}],
"title":"API Title",
"password":"Welcome123!"
}

I believe so. The only ambiguity is what type should be. PRIMARY is an inferred value, so that may need to change to something else. I'll know for sure after the fix is in place and will update here.

Hey Tim,

Is there any update on this solution being available?

Thanks!

The fix has been submitted and should be making it's way to production soon. Keep an eye out for the property to be added in the SDK release notes (readme in the repo).

This fix has made it to prod. The developer center will be updated with the new docs this week. Here's the schema for the Contact object now:

"Contact": {
  "type": "object",
  "properties": {
    "address": {
      "type": "string",
      "description": "Email address or phone number for this contact type"
    },
    "display": {
      "type": "string",
      "description": "Formatted version of the address property",
      "readOnly": true
    },
    "mediaType": {
      "type": "string",
      "enum": [
        "PHONE",
        "EMAIL",
        "SMS"
      ]
    },
    "type": {
      "type": "string",
      "enum": [
        "PRIMARY",
        "WORK",
        "WORK2",
        "WORK3",
        "WORK4",
        "HOME",
        "MOBILE",
        "MAIN"
      ]
    },
    "extension": {
      "type": "string",
      "description": "Use extension instead of address for setting internal extensions"
    }
  }

Maybe I'm mis-reading this, but I'm getting a 400 back trying to update the extension for a user with this JSON:

{
"name":"Ronni Gee",
"department":"CAM - Customer Service",
"email":"rgee@cochlear.com",
"addresses":[
{"extension":"8263"},
{"address":"+13032642863","mediaType":"PHONE","type":"WORK2"}],
"version":12,
"title":"Account Service Manager",
"password":"xxxxxxxx"
}

I think the issue is that you need to specify mediaType and type along with extension. If you can provide a correlation ID, I can take a look (the fix for missing errors still isn't in prod yet).

Here you go.

inin-correlation-id: 366493ba-b7e4-44f1-bc7f-e45b378d9d10

URL: /api/v2/users/867d46b3-852a-4bb7-b322-4131bb91a3db

Body:

{
"name":"Robert Garza",
"department":"CAM - Reimbursement",
"email":"rgarza@cochlear.com",
"addresses":[
{
"extension":"8261",
"mediaType":"PHONE",
"type":"WORK"},
{
"address":"+13032642161",
"mediaType":"PHONE",
"type":"WORK2"}],
"title":"Test",
"password":"Welcome1"
}

Make sure you include the entity's version when you update it.

Caught application error [API Exception 400:"Bad Request" : Validation error(s): [API Exception 400:"Bad Request" : Illegal value for field: version, Reason: Missing data for required field.]]

Oh, dang it! I knew that... Hold, please.

That was it, thanks!

1 Like

Although, when I look at the user in admin, their contact info still doesn't look right... See screen shots in uploaded jpg.

It looks like the extension isn't being saved quite correctly, so the UI is having a little trouble with it. I've opened API-2626 for this issue.

To work around, make your UI a little bigger and clear the first part of the phone number (it's populated with +1) and then you can edit the extension and save it.

The problem is that I have 150 users to update, which I plan to do with the API when it is working correctly. Can I do it as it sits today, or do I need to wait for this SCR to be resolved first?