Hallo Ihr,
ich bin neu und grüße erst einmal alle die das hier sehen
Ich habe eine Frage bzgl. der Restsharp - Anbindung an die REST - API von Shopware.
Das Abfragen von Artikelinformationen habe ich erfolgreich abgeschlossen jedoch hänge ich gerade bei den “PUT” versuchen.
Meine Funktion sieht wie folgt aus:
private void PutArticleStock(string URL)
{
var client = new RestClient(URL)
{
Authenticator = new DigestAuthenticator(user, pass)
};
Data d = new Data();
d.mainDetail = new MainDetail();
d.mainDetail.inStock = 55;
var request = new RestRequest("articles/{id}", Method.PUT);
request.AddUrlSegment("id", 3.ToString(CultureInfo.InvariantCulture));
var adt = JsonConvert.SerializeObject(d).ToString(CultureInfo.InvariantCulture);
request.AddParameter("application/json; charset=utf-8", adt, ParameterType.RequestBody);
var iResponse = client.Execute(request);
}
public class DigestAuthenticator :
IAuthenticator
{
private readonly string _user;
private readonly string _pass;
public DigestAuthenticator(string user, string pass)
{
_user = user;
_pass = pass;
}
public void Authenticate(IRestClient client, IRestRequest request)
{
request.Credentials = new NetworkCredential(_user, _pass);
}
}
Wenn ich das Probramm jetzt laufen lasse erscheinen mir folgende Meldungen:
Das JSON das erzeugt wird sieht so aus:
{"id":0,"mainDetailId":0,"supplierId":0,"taxId":0,"priceGroupId":null,"filterGroupId":null,"configuratorSetId":null,"name":null,"description":null,"descriptionLong":null,"added":null,"active":false,"pseudoSales":0,"highlight":false,"keywords":null,"metaTitle":null,"changed":null,"priceGroupActive":false,"lastStock":false,"crossBundleLook":0,"notification":false,"template":null,"mode":0,"availableFrom":null,"availableTo":null,"mainDetail":{"id":0,"articleId":0,"unitId":0,"number":null,"supplierNumber":null,"kind":0,"additionalText":null,"active":false,"inStock":55,"stockMin":0,"weight":null,"width":null,"len":null,"height":null,"ean":null,"position":0,"minPurchase":0,"purchaseSteps":null,"maxPurchase":null,"purchaseUnit":null,"referenceUnit":null,"packUnit":null,"shippingFree":false,"releaseDate":null,"shippingTime":null,"prices":null,"attribute":null,"configuratorOptions":null},"tax":null,"propertyValues":null,"supplier":null,"propertyGroup":null,"customerGroups":null,"images":null,"configuratorSet":null,"links":null,"downloads":null,"categories":null,"similar":null,"related":null,"details":null,"seoCategories":null}