Skip to content

Latest commit

 

History

History
65 lines (52 loc) · 1.07 KB

POST-translation.md

File metadata and controls

65 lines (52 loc) · 1.07 KB

POST - api/translation/array

Last updated: 04.08.17 by Jonas Solsvik

Request example

HTTP Method

POST

URL

http://localhost:5000/api/translation

JSON body

{
    "clientKey": "Ordbase",
    "languageKey": "en",
    "containerKey": "error_messages",
    "key": "error_create_client",
    "text": "default",
    "isComplete": false
}

JSON body type

Translation

Status response codes

CREATED 201
BAD REQUEST 400

Implementation draft - asp.net core mvc 1.1.2

TranslationController.cs

[HttpPost("api/translation")]
public IActionResult Create([FromBody] Translation translation) 
{   
    if (translation == null)
        return  BadRequest();

    return _translationRepo.Create(translation);
} 

TranslationRepository.cs

public IActionResult Create(Translation translation) 
{   
    _context.Translation.Add(translation);
    _context.SaveChanges();
    return new StatusCodeResult(201);
}