Update the label or schema of an existing custom metadata field.
200 Custom metadata definition successfully updated. In the response, you will get the field id, field name and, field schema. 400 A 400 response is returned along with an errors object with the key-value pair of all the errors if there is an error in schema object validation. 404: Not Found If no custom metadata is found with this id, 404 is returned
Copy {
"id" : "field_id" ,
"name" : "price" ,
"label" : "price" ,
"schema" : {
"type" : "Number" ,
"minValue" : 2000 ,
"maxValue" : 5000
}
}
Copy {
"message" : "Invalid field object" ,
"help" : "For support kindly contact us at support@imagekit.io ." ,
"errors" : {
"minValue" : "should be of type number" ,
"maxLength" : "not allowed for this type"
}
}
cURL Node.js Python PHP Java Ruby Go .Net
Copy curl -X PATCH "https://api.imagekit.io/v1/customMetadataFields/field_id" \
-H 'Content-Type: application/json' \
-u your_private_key: -d '
{
"schema": {
"minValue": 500,
"maxValue": 2500
}
}
'
Copy var ImageKit = require ( "imagekit" );
var imagekit = new ImageKit ({
publicKey : "your_public_api_key" ,
privateKey : "your_private_api_key" ,
urlEndpoint : "https://ik.imagekit.io/your_imagekit_id/"
});
var fieldId = "field_id" ;
imagekit .updateCustomMetadataField (
fieldId ,
{
schema : {
minValue : 500 ,
maxValue : 2500
}
} ,
function (error , result) {
if (error) console .log (error);
else console .log (result);
}
);
Copy from imagekitio import ImageKit
imagekit = ImageKit (
public_key = 'your_public_api_key' ,
private_key = 'your_private_api_key' ,
url_endpoint = 'https://ik.imagekit.io/your_imagekit_id/'
)
update_custom_metadata_fields = imagekit . update_custom_metadata_fields (field_id = "id" ,
options = UpdateCustomMetadataFieldsRequestOptions (label = "test-update" ,
schema = CustomMetadataFieldsSchema (
min_value = 100 ,
max_value = 200 ))
)
print ( "Update custom metadata field-" , update_custom_metadata_fields, end = "\n\n" )
# Raw Response
print (update_custom_metadata_fields.response_metadata.raw)
# print the label of updated custom metadata fields
print (update_custom_metadata_fields.label)
# print the schema's min value of updated custom metadata fields
print (update_custom_metadata_fields.schema.min_value)
Copy use ImageKit \ ImageKit ;
$public_key = "your_public_api_key" ;
$your_private_key = "your_private_api_key" ;
$url_end_point = "https://ik.imagekit.io/your_imagekit_id" ;
$imageKit = new ImageKit (
$public_key ,
$your_private_key ,
$url_end_point
);
$body = [
"schema" => [
"minValue" => 500
"maxValue" => 2500
]
];
$customMetadataFieldId = 'field_id' ;
$updateCustomMetadataField = $imageKit -> updateCustomMetadataField ( $customMetadataFieldId , $body ) ;
echo ( "Update Custom Metadata Field : " . json_encode ( $updateCustomMetadataField )) ;
Copy CustomMetaDataFieldSchemaObject schemaObject = new CustomMetaDataFieldSchemaObject() ;
schemaObject . setMinValue ( 500 );
schemaObject . setMaxValue ( 2500 );
CustomMetaDataFieldUpdateRequest customMetaDataFieldUpdateRequest = new CustomMetaDataFieldUpdateRequest() ;
customMetaDataFieldUpdateRequest . setId ( "field_id" );
customMetaDataFieldUpdateRequest . setLabel ( "" );
customMetaDataFieldUpdateRequest . setSchema (schemaObject);
ResultCustomMetaDataField resultCustomMetaDataField = ImageKit.getInstance().updateCustomMetaDataFields(customMetaDataFieldUpdateRequest);
Copy imagekitio = ImageKitIo :: Client . new ( "your_private_key" , "your_public_key" , "your_url_endpoint" )
imagekitio . update_custom_metadata_field(
id: 'field_id' , #required
schema: { #required if label not available
minValue: 500 ,
maxValue: 2500
}
)
Copy // Atleast Label or Schema is required
resp, err := ik.Metadata. UpdateCustomField (ctx, "field_id" , UpdateCustomFieldParam {
Label: "Cost" ,
Schema: {
MinValue: 100 ,
MaxValue: 2500 ,
},
})
Copy var imagekit = new ImageKit({
publicKey : "your_public_api_key",
privateKey : "your_private_api_key",
urlEndpoint : "https://ik.imagekit.io/your_imagekit_id/"
});
CustomMetaDataFieldUpdateRequest requestUpdateModel = new CustomMetaDataFieldUpdateRequest
{
Id = "field_Id",
};
CustomMetaDataFieldSchemaObject updateschema = new CustomMetaDataFieldSchemaObject
{
minValue = 500,
maxValue = 2500
};
requestUpdateModel.schema = updateschema;
ResultCustomMetaDataField resultCustomMetaDataFieldUpdate = imagekit.UpdateCustomMetaDataFields(requestUpdateModel);