Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7772715
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:56:40+00:00 2026-06-01T16:56:40+00:00

Im trying to create a POST method for my AddTagtoGroup which looks like this

  • 0

Im trying to create a POST method for my AddTagtoGroup

which looks like this (altho still confused as string group never seems to be used):

    List<Group> Groups = new List<Group>();
    List<Tag> tags = new List<Tag>();
    public void AddTagtoGroup(string group, string tag)
    {
        var result = Groups.Where(n => String.Equals(n.GroupName, tag)).FirstOrDefault();
        if (result != null)
        {
            result.Tags.Add(new Tag() { TagName = tag });
        }
    }  

And my post method looks like this but im unsure what to put in the uri template?

        [OperationContract]
        [WebInvoke(Method = "POST",
 BodyStyle = WebMessageBodyStyle.Bare, 
RequestFormat = WebMessageFormat.Xml, 
ResponseFormat = WebMessageFormat.Xml, 
UriTemplate = "/AddTagtoGroup{group}{tag}")]
        void AddTagtoGroup(string group, string tag);

Or am I getting confused with GET and anything can go in the uri template?

Altho upon running my post with just bare as the message formatt I get the error saying that my operation contract must be wrapped so I changed this to WebMessageFormat.Wrapped

The uri template I just set to UriTemplate="/AddTagtoGroup" it runs but im not sure I can actually post anything to it or can I? Like I say bit confused with GET & POST.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-01T16:56:42+00:00Added an answer on June 1, 2026 at 4:56 pm

    If you’d like to be restful you have a couple of options.

    If it is just strings, you want to define it as follows. Note that there is no data contracts needed. The downside is that if you have 100 tags, you’ll have to make a 100 calls.

    [OperationContract]
    [WebInvoke(Method = "POST", UriTemplate = "/groups/{group}/tags")
    public void AddTagsToGroup(string groupName, string tag)
    {
      // do what you need to do
    }
    

    To batch them up, you can do the following:

    [OperationContract]
    [WebInvoke(Method = "POST", UriTemplate = "/groups/{group}/tags")
    public void AddTagsToGroup(string groupName, string[] tags)
    {
      // do what you need to do
    }
    

    Now, there are some problems with this too, in particular if you’d like your payload to be self describing like:

    <Tags> 
       <Tag>tag1</Tag>
       <Tag>tag2</Tag>
    </Tags>
    

    In this case I’d define a data contract Tag as you did and post it as follows:

    [WebInvoke(Method = "POST", UriTemplate = "/groups/{group}/tags")
    public void AddTagsToGroup(string groupName, Tag[] tags)
    {
      // do what you need to do
    }
    

    Or wrap the tags request as follows:

    [CollectionDataContract]
    public class Tags : List<Tag>
    {
    
    }
    

    and define the signature as follows:

    [WebInvoke(Method = "POST", UriTemplate = "/groups/{group}/tags")
    public void AddTagsToGroup(string groupName, Tags tags)
    {
      // do what you need to do
    }
    

    The choice is really yours. The WCF REST help page will give you the exact format to post.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to create a POST request, unfortunately the body of the POST never
I'm trying to create an XML string and pass it to another method where
I'm trying to create a a custom post method but i'm having trouble finding
I'm trying to create a post button that inserts the latest posts into a
I am trying to create a post request to the tumblr api. Shown below
Im trying to create an ajax (post) event that will populate a table in
Help, I'm trying to create a new post in my wordpress blog with custom
Im trying to create a script that will post a notification stored in a
I'm trying to create an auto generated post excerpt from the current page's post
I am trying to create a zip file from post attachments in wordpress .

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.