Skip to content
DataMiner DoJo

More results...

Generic selectors
Exact matches only
Search in title
Search in content
Post Type Selectors
Search in posts
Search in pages
Search in posts
Search in pages
Log in
Menu
  • Updates & Insights
  • Questions
  • Learning
    • E-learning Courses
    • Empower Replay: Limited Edition
    • Tutorials
    • Open Classroom Training
    • Certification
      • DataMiner Fundamentals
      • DataMiner Configurator
      • DataMiner Automation
      • Scripts & Connectors Developer: HTTP Basics
      • Scripts & Connectors Developer: SNMP Basics
      • Visual Overview – Level 1
      • Verify a certificate
    • Video Library
    • Books We Like
    • >> Go to DataMiner Docs
  • Expert Center
    • Solutions & Use Cases
      • Solutions
      • Use Case Library
    • Markets & Industries
      • Media production
      • Government & defense
      • Content distribution
      • Service providers
      • Partners
      • OSS/BSS
    • Agile
      • Agile Webspace
      • Everything Agile
        • The Agile Manifesto
        • Best Practices
        • Retro Recipes
      • Methodologies
        • The Scrum Framework
        • Kanban
        • Extreme Programming
      • Roles
        • The Product Owner
        • The Agile Coach
        • The Quality & UX Coach (QX)
    • DataMiner DevOps Professional Program
      • About the DevOps Program
      • DataMiner DevOps Support
  • Downloads
  • More
    • DataMiner Releases & Updates
    • Feature Suggestions
    • Climb the leaderboard!
    • Swag Shop
    • Contact
    • Global Feedback Survey
  • PARTNERS
    • All Partners
    • Technology Partners
    • Strategic Partner Program
    • Deal Registration
  • >> Go to dataminer.services

User Defined API How To Get Data From Request Body?

Solved353 views14th November 2024User Defined APIs
0
João Azevedo237 13th November 2024 0 Comments

Hello everyone! I’m trying to make a User Defined API, but I don’t know how to access the request body values ​​correctly, i keep getting the error ” ‘JobData’ does not contain a definition for ‘workOrderId’ and no accessible extension method ‘workOrderId’ accepting a first argument of type ‘JobData’ could be found (are you missing a using directive or an assembly reference?)”, and the error occurs for all accessed data. What would be the correct method of accessing and manipulating this information?

Here is my code:

public class JobData
{
[JsonProperty(“jobId”)]
public string JobID { get; set; }

[JsonProperty(“primaryKey”)]
public string PrimaryKey { get; set; }

[JsonProperty(“name”)]
public string Name { get; set; }

[JsonProperty(“workOrderId”)]
public string WorkOrderId { get; set; }

[JsonProperty(“startsAt”)]
public string StartsAt { get; set; }

[JsonProperty(“endsAt”)]
public string EndsAt { get; set; }

[JsonProperty(“recurrenceType”)]
public string RecurrenceType { get; set; }

[JsonProperty(“site”)]
public string Site { get; set; }

[JsonProperty(“type”)]
public string Type { get; set; }

[JsonProperty(“client”)]
public string Client { get; set; }

[JsonProperty(“serviceDefinitionName”)]
public string ServiceDefinitionName { get; set; }

[JsonProperty(“serviceDefinitionGroup”)]
public string ServiceDefinitionGroup { get; set; }
}

var requestBody = JsonConvert.DeserializeObject<JobData>(requestData.RawBody);

string primaryKey = $”{requestBody.workOrderId}/{requestBody.serviceDefinitionName}/{requestBody.serviceDefinitionGroup}”;

var requestInfo = new
{
Method = requestData.RequestMethod.ToString(),
Body = new JobData {
JobID = Guid.NewGuid().ToString(),
PrimaryKey = primaryKey,
Name = requestBody.name,
WorkOrderId = requestBody.workOrderId,
StartsAt = requestBody.startsAt,
EndsAt = requestBody.endsAt,
RecurrenceType = requestBody.recurrenceType,
Site = requestBody.site,
Type = requestBody.type,
Client = requestBody.client,
ServiceDefinitionName = requestBody.serviceDefinitionName,
ServiceDefinitionGroup = requestBody.serviceDefinitionGroup
}
};

This is the body sent in the request:

{
“name”: “Fight Night”,
“workOrderId”: “73-1”,
“startsAt”: “2024-11-30”,
“endsAt”: “2024-11-31”,
“recurrenceType”: “Single Shot”,
“site”: “ION”,
“type”: “Live”,
“client”: “Combate”,
“serviceDefinitionGroup”: “G”,
“serviceDefinitionName”: “Processor”
}

João Azevedo Selected answer as best 14th November 2024

1 Answer

  • Active
  • Voted
  • Newest
  • Oldest
3
Wouter Van Robays [SLC] [DevOps Enabler]1.14K Posted 14th November 2024 1 Comment

Hi João,

It looks like you try to access the properties from your ‘requestData’ class using the lowercase name.

Instead of calling ‘requestData.workOrderId’, make sure to call ‘requestData.WorkOrderId’, the same for other properties you call in your code.

To give some background, your JSON properties are camelCase, and C# properties are typically PascalCase. To convert these correctly, JsonProperty attributes are used where you specify the name of your JSON property, so it can be correctly translated to your C# properties. You are doing this correctly, only you have to use the PascalCase when accessing C# properties.

I also want to mention that these type of compilation errors are more easy to spot using a code editor like Visual Studio, which you can extend with DataMiner Integration Studio (DIS).

I hope this helps you further.

João Azevedo Selected answer as best 14th November 2024
João Azevedo commented 14th November 2024

Hi Wouter, hope you're well! Thank you for your help, this was really the problem.

Please login to be able to comment or post an answer.

My DevOps rank

DevOps Members get more insights on their profile page.

My user earnings

0 Dojo credits

Spend your credits in our swag shop.

0 Reputation points

Boost your reputation, climb the leaderboard.

Promo banner DataMiner DevOps Professiona Program
DataMiner Integration Studio (DIS)
Empower Katas
Privacy Policy • Terms & Conditions • Contact

© 2025 Skyline Communications. All rights reserved.

DOJO Q&A widget

Can't find what you need?

? Explore the Q&A DataMiner Docs