1

I didn't find any client.Questions.Add method.
So, how do I use the StacMan library to add a new question ?

Any sample C# example?

1
  • I'm voting to close this question as it's specific to a 3rd-party library and should be posted as a comment or "answer" under that library's post. Commented Feb 16, 2018 at 19:00

2 Answers 2

2

As Brock Adams stated in his answer, you can't do this via the StacMan library.
Might I suggest an alternative?

You should be able to add new questions via the SEStandard library at SEStandard - A .NET Standard 1.1 compliant Stack Exchange client library that supports API v2.2.

using System.Threading.Tasks;
using RavinduL.SEStandard;
using Scopes = RavinduL.SEStandard.Models.Scopes;

var client = new StackExchangeClient
(
    clientId: ...,
    key: ...,

    // The WriteAccess scope and an access token are required to add questions to Stack Exchange.
    scopes: Scopes.WriteAccess,
    accessToken: ...
);

var query = await client.Questions.AddAsync
(
    title: ...,
    body: ...,
    tags: new string[] { ... },
    site: ...,

    // To preview the effects of adding instead of actually adding the question to Stack Exchange,
    preview: true
);

The variable query would be a Wrapper<Question> object. query.Items[0] would be the question that was just added (a Question object).

More documentation is available at the Stack Apps link above, and at the GitHub Repository.

Obligatory: I developed the SEStandard library.

2
  • I think I will need some more help Ravindu. My is Win10 UWP application and your library is .NET 1.1 standard, which is what I wanted. I am stuck at AccessToken, I am not sure what code to write for OAuth authentication with StackOverflow. I had earlier used Google API Library that automatically invokes Browser instance for authentication, but I am not sure how it will work with StackOverflow, Can you help me with an example, so that I can have accessToken string . - Thanks.
    – Neha
    Commented Mar 1, 2018 at 11:17
  • @Neha unlike the Google API client, SEStandard doesn’t show its own web browser. Instead, you’ll have to direct the user to an authentication prompt whose URL can be retrieved via the StackExchangeClient object, and handle redirection from it. I’ve documented the process, with an example, here.
    – ravindUwU
    Commented Mar 1, 2018 at 15:58
0

You can't.

StacMan hasn't been updated since September 2014, and only supports the API through version 2.1.

The API didn't have a /questions/add route until version 2.2.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .