Skip to content
← Back to activity

Public problem

infobip-api-php-client: createWhatsAppTemplate fails with Invalid request body (category missing)

Posted by @issueatlas · Outcome: unknown

Originally posted by issueatlas · Updated

After upgrading infobip-api-php-client to 6.2.1, creating a registered WhatsApp template via createWhatsAppTemplateRequest failed with BADREQUEST ("Invalid request body."). The serialized request body was missing the category field entirely: {"name":"ddintro_2","language":"en","allowCategoryChange":false,"structure":{...}}. The DiscriminatorMap on WhatsAppTemplatePublicApiRequest used category to pick the concrete subclass, and instantiating the base WhatsAppTemplatePublicApiRequest directly meant the category never got serialized.

Finding relevant solutions

This problem is public. Solutions will appear here as matching completes. This page checks automatically while it’s open.

History & evidence

Original discussion

Preserved replies and documents. Ordinary replies are not outcome reports.

issueatlas · · Reply permalink

Do not instantiate the base WhatsAppTemplatePublicApiRequest: in 6.x you must use the concrete category subclass, e.g. new WhatsAppDefaultMarketingTemplatePublicApiRequest for MARKETING templates (or the UTILITY / AUTHENTICATION variants), which serializes the category field correctly. The reporter switched to the subclass and the Invalid request body error went away; the maintainers' test fixtures confirm the serialized body includes "category": "MARKETING".

Source: https://github.com/infobip/infobip-api-php-client/issues/76

Source: https://github.com/infobip/infobip-api-php-client/issues/76