Update Variant (CSM-CRMV-04)

This API endpoint allows for the specific update of base information for a single product variant. It ensures data security through the requirement of a valid Authorization token and possession of the MNRM permission.

Request Paramenters

Mandatory Parameters

  • customerId: The active customer’s ID
  • configuratorRawMaterialId: The parent product’s ID
  • variantId: The ID of the variant to be updated

HEADER:

  • Authorization: Requires a Bearer token (example: Bearer {currentToken})
				
					[PUT] /api-catalog/v2
/customers/{customerId:long}
/products/{configuratorRawMaterialId:long}
/variants/{variantId}
{
  "isActive": true,
  "warehouseQuantity": 0
}

				
			

Response

  • 200 OK: Indicates successful update of the product variant.
  • 400 Bad Request: The request is invalid. Check if all required parameters are correct and included.
  • 401 Unauthorized: Authentication failed. Ensure your token is valid and has not expired.
				
					[200] OK

[400] Bad Request

[401] Unauthorized
				
			

Example
Here's a sample C# async method to help users understand how to implement this endpoint:

				
					using System;
using System.Threading.Tasks;
using RestSharp;

public static async Task<bool> UpdateProductVariantAsync(long customerId, long configuratorRawMaterialId, long variantId, bool isActive, int warehouseQuantity)
{
    var client = new RestClient("https://yourapi.com");
    var request = new RestRequest($"/api-catalog/v2/customers/{customerId}/products/{configuratorRawMaterialId}/variants/{variantId}", Method.Put);

    var currentToken = "token-recuperato-dalla-login";
    request.AddHeader("Authorization", $"Bearer {currentToken}");
    
    request.AddJsonBody(new
    {
        isActive = isActive,
        warehouseQuantity = warehouseQuantity
    });

    try
    {
        var response = await client.ExecuteAsync(request);

        if (response.IsSuccessful)
        {
            Console.WriteLine("Product variant updated successfully.");
            return true;  // Aggiornamento avvenuto con successo
        }
        else
        {
            Console.WriteLine($"Error: {response.StatusCode} - {response.ErrorMessage}");
            return false; // Errore durante l'aggiornamento
        }
    }
    catch (Exception ex)
    {
        Console.WriteLine($"Exception: {ex.Message}");
        return false; // Eccezione catturata
    }
}

				
			

Additional documentation and support