Reputation: 12646
I can do a POST request from some http provider, POSTMAN, CURL, whatever to upload data to AWS Cloud Search like this:
myawsdomain.us-east-1.cloudsearch.amazonaws.com/2017-01-01/documents/batch
(with JSON body included)
How do I do this from the latest .NET SDK? I can do searches, but I am having trouble writing data to AWS CloudSearch.
Note, I don't need help parsing/creating JSON in .NET - I can do that, just the commands to write to AWS. I can't find any other info besides the docs.
Upvotes: 2
Views: 964
Reputation: 12646
This code successfully writes to the Cloud Search Domain:
using Amazon.CloudSearchDomain;
using Amazon.CloudSearchDomain.Model;
var domainConfig = new AmazonCloudSearchDomainConfig;
{
ServiceURL = "http://myawsdomain.us-east-1.cloudsearch.amazonaws.com"
};
var cloudSearch = new Amazon.CloudSearchDomain.AmazonCloudSearchDomainClient(domainConfig);
var path = @"C:\Code\myjsonfile.txt";
var ms = new MemoryStream();
FileStream jsonFileToUpload = new FileStream(path, FileMode.Open, FileAccess.Read);
var upload = new Amazon.CloudSearchDomain.Model.UploadDocumentsRequest()
{
ContentType = ContentType.ApplicationJson,
Documents = jsonFileToUpload
};
var response = cloudSearch.UploadDocuments(upload);
Upvotes: 1
Reputation: 1193
Not sure if the AWS .NET SDK has what you're looking for but this library might encapsulate the functionality you need:
https://github.com/martin-magakian/Amazing-Cloud-Search
It makes use of generics and is strongly typed - so it should be clean and fit nicely with your data model.
Upvotes: 0