Hello,
First of all, thanks for all the support provided regarding OpenAPI usage.
Problem
We are currently using the HubSpot OpenAPI spec to auto-generate a client for a Kotlin based application we are working on.
We’ve successfully integrated it and managed to generate all required code. Also made some tests to retrieve some entities and seems to be working like a charm.
After some testing, we are having an error with the Add records to a List operation (Probably happening with other operations on the List Membermship API).
As described in the specification, it should return a MembershipsUpdateResponse, and we are getting an error when the client tries to parse the reponse body, as it expecting some required fields that are not returned when adding a record to a List (e.g: recordIdsRemoved)
com.squareup.moshi.JsonDataException: Required value 'recordIdsRemoved' missing at $
at com.squareup.moshi.internal.Util.missingProperty(Util.java:660)
at com.squareup.moshi.kotlin.reflect.KotlinJsonAdapter.fromJson(KotlinJsonAdapter.kt:105)
at com.squareup.moshi.internal.NullSafeJsonAdapter.fromJson(NullSafeJsonAdapter.java:41)
at com.squareup.moshi.JsonAdapter.fromJson(JsonAdapter.java:70)
at com.hubspot.lists.api.MembershipsApi.putCrmV3ListsListIdMembershipsAddWithHttpInfo(MembershipsApi.kt:1405)
at com.hubspot.lists.api.MembershipsApi.putCrmV3ListsListIdMembershipsAdd(MembershipsApi.kt:225)
[...]
The actual response from the API is like (required fields are not present in the response):
{
"recordsIdsAdded": [
"13XXXXXXXX"
]
}
Workarround
After digging and debugging a bit the issue, we removed the required fields of MembershipsUpdateResponse from the local file for the OpenAPI specification we use and regenerated again all the code for the client.
This seems to be fixing the issue and we can now successfully run the Add records to a List operation.
I’ve already created a Github issue in case it helps to keep track of this issue/question:
- MembershipsUpdateResponse required fields are not returned on API operations · Issue #15 · HubSpot/HubSpot-public-api-spec-collection · GitHub
Thanks in advance