cancel
Showing results for 
Search instead for 
Did you mean: 

Duplicated keys in OData API response

Dear Community,

we are looking to build an integration using the OData API, however we noticed that there are duplicated keys in the response the API returns.
More specifically, we are trying to insert job applications. The above mentioned behavior occurs only if the respective job requisition has been assigned more than one screening questions.

Following is a sample request.

{
    "resume": {
        ... an attachment object
    },
    "jobReqId": 99887766,
    "jobApplicationQuestionResponse": [
        {
            "order": "1",
            "answer": "No"
        },
        {
            "order": "2",
            "answer": "3-5 years"
        }
    ],
    "coverLetter": {
        ... an attachment object
    },
    "candidateId": "44444",
    "appStatusSetItemId": "1234567",
    "appLocale": "en_GB"
}

This is the response we get.

{
    "d": {
        "__metadata": {
            "uri": "<API base URL>/JobApplication(2222L)",
            "type": "SFOData.JobApplication"
        },
        "jobReqId": "99887766",
        "candidateId": "44444",
        "appStatusSetItemId": "1234567",
        "appLocale": "en_GB",
        "applicationId": "2222",
        "resume": {
            ... attachment response
        },
        "jobApplicationQuestionResponse": {
            "__metadata": {
                "uri": "<API Base URL>/JobApplicationQuestionResponse???",
                "type": "SFOData.JobApplicationQuestionResponse"
            },
            "order": "1",
            "answer": "No"
        },
        "jobApplicationQuestionResponse": {
            "__metadata": {
                "uri": "<API base URL>/JobApplicationQuestionResponse???",
                "type": "SFOData.JobApplicationQuestionResponse"
            },
            "order": "2",
            "answer": "3-5 years"
        },
        "coverLetter": {
            ... attachment response
        }
    }
}

The problem is that the library we are using can't handle duplicated keys (see the properties "jobApplicationQuestionResponse" above) in the response.

Has any of you faced this issue? If so, could you please, describe how this can be solved?

Thank you for your input in advance!

Accepted Solutions (0)

Answers (2)

Answers (2)

gerald_reinhard
Product and Topic Expert
Product and Topic Expert

Hi Bence,

It this is really the response from the API:

uri": "<API Base URL>/JobApplicationQuestionResponse???",

I would say this is an issue with the API response the consumer can not fix. The API should not have data like his in the metadata token being returned. It should be a proper URL with the right keys. Might be worth to open a ticket to ask if this will be fixed soon or if this will take a while.

Workarounds for something like this are of cause possible, this would be the order I would try:

  • Check if they can use upsert instead of POST on the entity (https://apps.support.sap.com/sap/support/knowledge/en/2882860)
  • Switching to a HTTP connector instead of using the library
  • Using a CPI process in-between to filter out those records or correct the response
  • Changing the code in the library to cope with the situation or correct the data on the fly with dummy keys

Best regards

Gerald

0 Kudos

Hi Gerald,

thank you very much for your reply!

(Un)Fortunately, this occurs in a Salesdemo instance. Therefore, we can't submit an incident.
Since this didn't occur in the past, we believe that this is a temporary issue, which will be solved soon.

Thank you for the workarounds, too. We haven't tried to use the UPSERT operation yet. In my opinion, however, the solution would be to solve this issue and not implementing a workaround.
After all, this is a functionality that has been described in the latest version of the documentation as well.

Best regards,
Bence