Create a Field
POSThttps://euwest.api.elasticpath.com/v2/fields
- For Commerce, this endpoint creates a field.
- For Product Experience Manager, this endpoint creates an attribute.
Request
Responses
- 201
- 422
- 500
Created
Bad request. The request failed validation.
Internal server error. There was a system failure in the platform.
Authorization: http
name: bearerAuthtype: httpscheme: bearer
- csharp
- curl
- dart
- go
- http
- java
- javascript
- kotlin
- c
- nodejs
- objective-c
- ocaml
- php
- powershell
- python
- r
- ruby
- rust
- shell
- swift
- HTTPCLIENT
- RESTSHARP
var client = new HttpClient();
var request = new HttpRequestMessage(HttpMethod.Post, "https://euwest.api.elasticpath.com/v2/fields");
request.Headers.Add("Accept", "application/json");
request.Headers.Add("Authorization", "Bearer <token>");
var content = new StringContent("{\n \"data\": {\n \"default\": 0,\n \"description\": \"string\",\n \"enabled\": true,\n \"field_type\": \"string\",\n \"name\": \"string\",\n \"order\": 0,\n \"relationships\": {\n \"flow\": {\n \"data\": {\n \"id\": \"00000000-0000-0000-0000-000000000000\",\n \"type\": \"flow\"\n }\n }\n },\n \"required\": true,\n \"slug\": \"string\",\n \"type\": \"string\",\n \"validation_rules\": [\n {\n \"type\": \"enum\",\n \"options\": [\n \"string\"\n ],\n \"to\": \"customer\"\n }\n ]\n }\n}", null, "application/json");
request.Content = content;
var response = await client.SendAsync(request);
response.EnsureSuccessStatusCode();
Console.WriteLine(await response.Content.ReadAsStringAsync());
ResponseClear