DNVGL RP-O501 REST Api
API change historyEROSIVE WEAR IN PIPING SYSTEMS
Calculates erosion in mm/ton sand and mm/year for a set of components (Line object) and a single flow condition. Mixture velocity is also returned.
REQUEST SCHEMA: LineBlackOilStream
Consult the examples and sub-schemas for details on how to specify input.
Try itRequest
Request URL
Request headers
-
(optional)stringMedia type of the body sent to the API.
Request body
LineBlackOilStream
{
"FluidStream": {
"TemperatureStd": 15.6,
"Temperature": 50,
"PressureStd": 1.01325,
"Pressure": 63,
"GasMolWeight": 19,
"OilDensityStd": 800,
"WaterDensityStd": 1020,
"GasVolumetricRateStd": 1000000,
"OilVolumetricRateStd": 1000,
"WaterVolumetricRateStd": 10,
"GasViscosity": 1.5E-5,
"OilViscosity": 1E-4,
"WaterViscosity": 1E-3,
"GasCompressibilityFactor": 0.9
},
"ParticleStream": {
"ParticleDiameter": 150,
"ParticleMassFlowRate": 0.1,
"ErosiveAgent": {
"Name": "Quartz",
"Density": 2650,
"ReductionFactor": 1
}
},
"Line": {
"Tag": "BC-USC",
"ServiceLife": 20,
"Components": {
"Bends": [
{
"Material": {
"Name": "CarbonSteel",
"AngleDependency": "Ductile",
"Density": 7800,
"K": 0.000000002,
"N": 2.6
},
"Tag": "XMT elbow 5inch",
"GeometryFactor": 2,
"ErosionAllowance": 0.83,
"PipeDiameter": 0.1223,
"RadiusOfCurvature": 3
}
],
"Tees": [
{
"Material": {
"Name": "CarbonSteel",
"AngleDependency": "Ductile",
"Density": 7800,
"K": 0.000000002,
"N": 2.6
},
"Tag": "XMT Tee",
"GeometryFactor": 1,
"ErosionAllowance": 3,
"PipeDiameter": 0.1302
}
]
}
}
}
{
"type": "object",
"properties": {
"fluidStream": {
"type": "object",
"properties": {
"temperatureStd": {
"type": "number",
"description": "Temperature at standard (reference) condition: [deg C]",
"format": "double",
"nullable": true
},
"pressureStd": {
"type": "number",
"description": "Pressure at standard (reference) condition: [Bar abs]",
"format": "double",
"nullable": true
},
"gasMolWeight": {
"type": "number",
"description": "Mol weight (MW) of gas: [g/mol]",
"format": "double",
"nullable": true
},
"oilDensityStd": {
"type": "number",
"description": "Density of oil phase: [kg/m3]",
"format": "double",
"nullable": true
},
"waterDensityStd": {
"type": "number",
"description": "Density of water phase: [kg/m3]",
"format": "double",
"nullable": true
},
"gasViscosity": {
"type": "number",
"description": "Viscosity of gas phase: [Pas]",
"format": "double",
"nullable": true
},
"oilViscosity": {
"type": "number",
"description": "Viscosity of oil phase: [Pas]",
"format": "double",
"nullable": true
},
"waterViscosity": {
"type": "number",
"description": "Viscosity of water phase: [Pas]",
"format": "double",
"nullable": true
},
"gasCompressibilityFactor": {
"type": "number",
"description": "Gas compressibility factor: [-]",
"format": "double",
"nullable": true
},
"temperature": {
"type": "number",
"description": "Temperature: [deg C]",
"format": "double",
"nullable": true
},
"pressure": {
"type": "number",
"description": "Pressure: [bar absolute]",
"format": "double",
"nullable": true
},
"gasVolumetricRateStd": {
"type": "number",
"description": "Gas rate at standard conditions: [m3/day]",
"format": "double",
"nullable": true
},
"oilVolumetricRateStd": {
"type": "number",
"description": "Oil rate at standard conditions: [m3/day]",
"format": "double",
"nullable": true
},
"waterVolumetricRateStd": {
"type": "number",
"description": "Water rate at standard conditions: [m3/day]",
"format": "double",
"nullable": true
}
},
"additionalProperties": false,
"description": "Defines a single 'snapshot' of a fluid stream according to the simplified \"Black oil\" equation of state.\r\n\"Black oil\" assumes no flashing or absorption, meaning the gas fraction will behave as an ideal gas, and that\r\nthe oil and water phases retain their properties (density/viscosity) regardless of pressure or temperature.\r\nFlow rates are given with reference to a standard condition, for which pressure and temperature are known, i.e.\r\na volumetric gas flow rate in Sm3/d assumes that the gas density is equal to that of the reference condition\r\ngiven by PressureStd and TemperatureStd.\r\n \r\nMixture density and mixture viscosity are calculated based on the volume weighted fractions of gas. oil and\r\nwater, and these are used as inputs to the erosion calculations."
},
"particleStream": {
"type": "object",
"properties": {
"particleDiameter": {
"type": "number",
"description": "Representative particle diameter. Typically set to d50 for the particle size distribution: [microns]",
"format": "double",
"nullable": true
},
"particleMassFlowRate": {
"type": "number",
"description": "Particle mass flow rate: [g/s]",
"format": "double",
"nullable": true
},
"erosiveAgent": {
"type": "object",
"properties": {
"name": {
"type": "string",
"description": "Name of predefined erosive agent, or custom name (optional).",
"nullable": true
},
"density": {
"type": "number",
"description": "Density of erosive agent [kg/m3]",
"format": "double",
"nullable": true
},
"reductionFactor": {
"type": "number",
"description": "ReductionFactor [-] Correction factor enabling adjustment of the erosive response based on geometric properties\r\nof the erosive agents. For example, proppants would typically be modelled with ReductionFactor > 1.\r\nA value of 1.0 corresponds to standard RP-O501 models.",
"format": "double",
"nullable": true
}
},
"additionalProperties": false,
"description": "Describes the erosive agent present in a fluid stream.\r\n\r\nTo use predefined erosive agent properties (see separate endpoint), specify the name of the predefined\r\nerosive agent. In this case, the values of Density and ReductionFactor will be ignored,\r\nand the corresponding predefined erosive agent values will be applied.\r\nIf Name does not correspond to a predefined erosive agent, the values of Density, and ReductionFactor must be\r\nspecified."
}
},
"additionalProperties": false,
"description": "Defines the particle content in a fluid stream."
},
"line": {
"type": "object",
"properties": {
"tag": {
"type": "string",
"nullable": true
},
"serviceLife": {
"type": "number",
"format": "double",
"nullable": true
},
"components": {
"type": "object",
"properties": {
"bends": {
"type": "array",
"items": {
"type": "object",
"properties": {
"geometryFactor": {
"type": "number",
"description": "Correction factor applied to results in order to account for isometric effects (swirl) [-]",
"format": "double",
"nullable": true
},
"erosionAllowance": {
"type": "number",
"description": "Erosion allowance for component. Used for calculation of relative criticality [mm]",
"format": "double",
"nullable": true
},
"tag": {
"type": "string",
"description": "Component ID",
"nullable": true
},
"material": {
"type": "object",
"properties": {
"angleDependency": {
"enum": [
"Ductile",
"DuctileLegacy",
"Brittle"
],
"type": "string"
},
"name": {
"type": "string",
"description": "Name of predefined target material, or custom name (optional).",
"nullable": true
},
"density": {
"type": "number",
"description": "Density of target material [kg/m3]",
"format": "double",
"nullable": true
},
"k": {
"type": "number",
"description": "Constant of proportionality in RP-O501 response equation",
"format": "double",
"nullable": true
},
"n": {
"type": "number",
"description": "Velocity exponent in RP-O501 response equation",
"format": "double",
"nullable": true
}
},
"additionalProperties": false,
"description": "To use predefined target material properties (see separate endpoint), specify the name of the predefined\r\ntarget material. In this case, the values of AngleDependencyOption, Density, K and N will be ignored,\r\nand the corresponding predefined material values will be applied.\r\nIf Name does not correspond to a predefined target material, the values of AngleDependencyOption Density,\r\nK and N must be specified."
},
"pipeDiameter": {
"type": "number",
"description": "Diameter of pipe [m]",
"format": "double",
"nullable": true
},
"radiusOfCurvature": {
"type": "number",
"description": "Radius of curvature for the pipe, expressed in number of inner diameters [-]",
"format": "double",
"nullable": true
}
},
"additionalProperties": false,
"description": "Bend geometry model definition."
},
"nullable": true
},
"tees": {
"type": "array",
"items": {
"type": "object",
"properties": {
"geometryFactor": {
"type": "number",
"description": "Correction factor applied to results in order to account for isometric effects (swirl) [-]",
"format": "double",
"nullable": true
},
"erosionAllowance": {
"type": "number",
"description": "Erosion allowance for component. Used for calculation of relative criticality [mm]",
"format": "double",
"nullable": true
},
"tag": {
"type": "string",
"description": "Component ID",
"nullable": true
},
"material": {
"type": "object",
"properties": {
"angleDependency": {
"enum": [
"Ductile",
"DuctileLegacy",
"Brittle"
],
"type": "string"
},
"name": {
"type": "string",
"description": "Name of predefined target material, or custom name (optional).",
"nullable": true
},
"density": {
"type": "number",
"description": "Density of target material [kg/m3]",
"format": "double",
"nullable": true
},
"k": {
"type": "number",
"description": "Constant of proportionality in RP-O501 response equation",
"format": "double",
"nullable": true
},
"n": {
"type": "number",
"description": "Velocity exponent in RP-O501 response equation",
"format": "double",
"nullable": true
}
},
"additionalProperties": false,
"description": "To use predefined target material properties (see separate endpoint), specify the name of the predefined\r\ntarget material. In this case, the values of AngleDependencyOption, Density, K and N will be ignored,\r\nand the corresponding predefined material values will be applied.\r\nIf Name does not correspond to a predefined target material, the values of AngleDependencyOption Density,\r\nK and N must be specified."
},
"pipeDiameter": {
"type": "number",
"description": "Diameter of pipe at inlet/outlet [m]",
"format": "double",
"nullable": true
}
},
"additionalProperties": false,
"description": "Blinded tee geometry model definition."
},
"nullable": true
},
"reducers": {
"type": "array",
"items": {
"type": "object",
"properties": {
"geometryFactor": {
"type": "number",
"description": "Correction factor applied to results in order to account for isometric effects (swirl) [-]",
"format": "double",
"nullable": true
},
"erosionAllowance": {
"type": "number",
"description": "Erosion allowance for component. Used for calculation of relative criticality [mm]",
"format": "double",
"nullable": true
},
"tag": {
"type": "string",
"description": "Component ID",
"nullable": true
},
"material": {
"type": "object",
"properties": {
"angleDependency": {
"enum": [
"Ductile",
"DuctileLegacy",
"Brittle"
],
"type": "string"
},
"name": {
"type": "string",
"description": "Name of predefined target material, or custom name (optional).",
"nullable": true
},
"density": {
"type": "number",
"description": "Density of target material [kg/m3]",
"format": "double",
"nullable": true
},
"k": {
"type": "number",
"description": "Constant of proportionality in RP-O501 response equation",
"format": "double",
"nullable": true
},
"n": {
"type": "number",
"description": "Velocity exponent in RP-O501 response equation",
"format": "double",
"nullable": true
}
},
"additionalProperties": false,
"description": "To use predefined target material properties (see separate endpoint), specify the name of the predefined\r\ntarget material. In this case, the values of AngleDependencyOption, Density, K and N will be ignored,\r\nand the corresponding predefined material values will be applied.\r\nIf Name does not correspond to a predefined target material, the values of AngleDependencyOption Density,\r\nK and N must be specified."
},
"inletDiameter": {
"type": "number",
"description": "Inlet diameter of contraction [m]",
"format": "double",
"nullable": true
},
"outletDiameter": {
"type": "number",
"description": "Outlet diameter of contraction [m]",
"format": "double",
"nullable": true
},
"projectedAngleInDegrees": {
"type": "number",
"description": "Angle between the pipe axis and the surface of the contracting part of the pipe [deg]",
"format": "double",
"nullable": true
}
},
"additionalProperties": false,
"description": "Reducer/contraction geometry model definition."
},
"nullable": true
},
"erProbes": {
"type": "array",
"items": {
"type": "object",
"properties": {
"geometryFactor": {
"type": "number",
"description": "Correction factor applied to results in order to account for isometric effects (swirl) [-]",
"format": "double",
"nullable": true
},
"erosionAllowance": {
"type": "number",
"description": "Erosion allowance for component. Used for calculation of relative criticality [mm]",
"format": "double",
"nullable": true
},
"tag": {
"type": "string",
"description": "Component ID",
"nullable": true
},
"material": {
"type": "object",
"properties": {
"angleDependency": {
"enum": [
"Ductile",
"DuctileLegacy",
"Brittle"
],
"type": "string"
},
"name": {
"type": "string",
"description": "Name of predefined target material, or custom name (optional).",
"nullable": true
},
"density": {
"type": "number",
"description": "Density of target material [kg/m3]",
"format": "double",
"nullable": true
},
"k": {
"type": "number",
"description": "Constant of proportionality in RP-O501 response equation",
"format": "double",
"nullable": true
},
"n": {
"type": "number",
"description": "Velocity exponent in RP-O501 response equation",
"format": "double",
"nullable": true
}
},
"additionalProperties": false,
"description": "To use predefined target material properties (see separate endpoint), specify the name of the predefined\r\ntarget material. In this case, the values of AngleDependencyOption, Density, K and N will be ignored,\r\nand the corresponding predefined material values will be applied.\r\nIf Name does not correspond to a predefined target material, the values of AngleDependencyOption Density,\r\nK and N must be specified."
},
"pipeDiameter": {
"type": "number",
"description": "Diameter of pipe [m]",
"format": "double",
"nullable": true
},
"projectedAngleInDegrees": {
"type": "number",
"description": "Angle between the pipe axis and surface of the probe elements [deg]",
"format": "double",
"nullable": true
}
},
"additionalProperties": false,
"description": "Erosion probe (electrical resistivity probe) geometry model definition."
},
"nullable": true
},
"smoothPipes": {
"type": "array",
"items": {
"type": "object",
"properties": {
"geometryFactor": {
"type": "number",
"description": "Correction factor applied to results in order to account for isometric effects (swirl) [-]",
"format": "double",
"nullable": true
},
"erosionAllowance": {
"type": "number",
"description": "Erosion allowance for component. Used for calculation of relative criticality [mm]",
"format": "double",
"nullable": true
},
"tag": {
"type": "string",
"description": "Component ID",
"nullable": true
},
"material": {
"type": "object",
"properties": {
"angleDependency": {
"enum": [
"Ductile",
"DuctileLegacy",
"Brittle"
],
"type": "string"
},
"name": {
"type": "string",
"description": "Name of predefined target material, or custom name (optional).",
"nullable": true
},
"density": {
"type": "number",
"description": "Density of target material [kg/m3]",
"format": "double",
"nullable": true
},
"k": {
"type": "number",
"description": "Constant of proportionality in RP-O501 response equation",
"format": "double",
"nullable": true
},
"n": {
"type": "number",
"description": "Velocity exponent in RP-O501 response equation",
"format": "double",
"nullable": true
}
},
"additionalProperties": false,
"description": "To use predefined target material properties (see separate endpoint), specify the name of the predefined\r\ntarget material. In this case, the values of AngleDependencyOption, Density, K and N will be ignored,\r\nand the corresponding predefined material values will be applied.\r\nIf Name does not correspond to a predefined target material, the values of AngleDependencyOption Density,\r\nK and N must be specified."
},
"pipeDiameter": {
"type": "number",
"description": "Diameter of pipe [m]",
"format": "double",
"nullable": true
}
},
"additionalProperties": false,
"description": "Smooth pipe geometry model definition."
},
"nullable": true
},
"weldedJointsUpstream": {
"type": "array",
"items": {
"type": "object",
"properties": {
"geometryFactor": {
"type": "number",
"description": "Correction factor applied to results in order to account for isometric effects (swirl) [-]",
"format": "double",
"nullable": true
},
"erosionAllowance": {
"type": "number",
"description": "Erosion allowance for component. Used for calculation of relative criticality [mm]",
"format": "double",
"nullable": true
},
"tag": {
"type": "string",
"description": "Component ID",
"nullable": true
},
"material": {
"type": "object",
"properties": {
"angleDependency": {
"enum": [
"Ductile",
"DuctileLegacy",
"Brittle"
],
"type": "string"
},
"name": {
"type": "string",
"description": "Name of predefined target material, or custom name (optional).",
"nullable": true
},
"density": {
"type": "number",
"description": "Density of target material [kg/m3]",
"format": "double",
"nullable": true
},
"k": {
"type": "number",
"description": "Constant of proportionality in RP-O501 response equation",
"format": "double",
"nullable": true
},
"n": {
"type": "number",
"description": "Velocity exponent in RP-O501 response equation",
"format": "double",
"nullable": true
}
},
"additionalProperties": false,
"description": "To use predefined target material properties (see separate endpoint), specify the name of the predefined\r\ntarget material. In this case, the values of AngleDependencyOption, Density, K and N will be ignored,\r\nand the corresponding predefined material values will be applied.\r\nIf Name does not correspond to a predefined target material, the values of AngleDependencyOption Density,\r\nK and N must be specified."
},
"pipeDiameter": {
"type": "number",
"description": "Diameter of pipe [m]",
"format": "double",
"nullable": true
},
"projectedAngleInDegrees": {
"type": "number",
"description": "Angle between the pipe axis and flow-facing surface of the weld [deg]",
"format": "double",
"nullable": true
}
},
"additionalProperties": false,
"description": "Welded joint (flow-facing side) geometry model definition."
},
"nullable": true
},
"weldedJointsDownstream": {
"type": "array",
"items": {
"type": "object",
"properties": {
"geometryFactor": {
"type": "number",
"description": "Correction factor applied to results in order to account for isometric effects (swirl) [-]",
"format": "double",
"nullable": true
},
"erosionAllowance": {
"type": "number",
"description": "Erosion allowance for component. Used for calculation of relative criticality [mm]",
"format": "double",
"nullable": true
},
"tag": {
"type": "string",
"description": "Component ID",
"nullable": true
},
"material": {
"type": "object",
"properties": {
"angleDependency": {
"enum": [
"Ductile",
"DuctileLegacy",
"Brittle"
],
"type": "string"
},
"name": {
"type": "string",
"description": "Name of predefined target material, or custom name (optional).",
"nullable": true
},
"density": {
"type": "number",
"description": "Density of target material [kg/m3]",
"format": "double",
"nullable": true
},
"k": {
"type": "number",
"description": "Constant of proportionality in RP-O501 response equation",
"format": "double",
"nullable": true
},
"n": {
"type": "number",
"description": "Velocity exponent in RP-O501 response equation",
"format": "double",
"nullable": true
}
},
"additionalProperties": false,
"description": "To use predefined target material properties (see separate endpoint), specify the name of the predefined\r\ntarget material. In this case, the values of AngleDependencyOption, Density, K and N will be ignored,\r\nand the corresponding predefined material values will be applied.\r\nIf Name does not correspond to a predefined target material, the values of AngleDependencyOption Density,\r\nK and N must be specified."
},
"pipeDiameter": {
"type": "number",
"description": "Diameter of pipe [m]",
"format": "double",
"nullable": true
},
"weldHeight": {
"type": "number",
"description": "Height of weld as measured from the pipe wall [mm]",
"format": "double",
"nullable": true
}
},
"additionalProperties": false,
"description": "Welded joint (downstream side) geometry model definition."
},
"nullable": true
}
},
"additionalProperties": false,
"description": "Contains definition of all components on the line. At least one of the arrays containing at least one component,\r\nhas to be specified."
}
},
"additionalProperties": false,
"description": "Contains the Line definition, i.e. the virtual pipe containing a group of components for which erosion\r\nis to be calculated."
}
},
"additionalProperties": false,
"description": "",
"example": "{\r\n\t\"FluidStream\": {\r\n\t\t\"TemperatureStd\": 15.6,\r\n\t\t\"Temperature\": 50,\r\n\t\t\"PressureStd\": 1.01325,\r\n\t\t\"Pressure\": 63,\r\n\t\t\"GasMolWeight\": 19,\r\n\t\t\"OilDensityStd\": 800,\r\n\t\t\"WaterDensityStd\": 1020,\r\n\t\t\"GasVolumetricRateStd\": 1000000,\r\n\t\t\"OilVolumetricRateStd\": 1000,\r\n\t\t\"WaterVolumetricRateStd\": 10,\r\n\t\t\"GasViscosity\": 1.5E-5,\r\n\t\t\"OilViscosity\": 1E-4,\r\n\t\t\"WaterViscosity\": 1E-3,\r\n\t\t\"GasCompressibilityFactor\": 0.9\r\n\t},\r\n\t\"ParticleStream\": {\r\n\t\t\"ParticleDiameter\": 150,\r\n\t\t\"ParticleMassFlowRate\": 0.1,\r\n\t\t\"ErosiveAgent\": {\r\n\t\t\t\"Name\": \"Quartz\",\r\n\t\t\t\"Density\": 2650,\r\n\t\t\t\"ReductionFactor\": 1\r\n\t\t}\r\n\t},\r\n\t\"Line\": {\r\n\t\t\"Tag\": \"BC-USC\",\r\n\t\t\"ServiceLife\": 20,\r\n\t\t\"Components\": {\r\n\t\t\t\"Bends\": [\r\n\t\t\t\t{\r\n\t\t\t\t\t\"Material\": {\r\n\t\t\t\t\t\t\"Name\": \"CarbonSteel\",\r\n\t\t\t\t\t\t\"AngleDependency\": \"Ductile\",\r\n\t\t\t\t\t\t\"Density\": 7800,\r\n\t\t\t\t\t\t\"K\": 0.000000002,\r\n\t\t\t\t\t\t\"N\": 2.6\r\n\t\t\t\t\t},\r\n\t\t\t\t\t\"Tag\": \"XMT elbow 5inch\",\r\n\t\t\t\t\t\"GeometryFactor\": 2,\r\n\t\t\t\t\t\"ErosionAllowance\": 0.83,\r\n\t\t\t\t\t\"PipeDiameter\": 0.1223,\r\n\t\t\t\t\t\"RadiusOfCurvature\": 3\r\n\t\t\t\t}\r\n\t\t\t],\r\n\t\t\t\"Tees\": [\r\n\t\t\t\t{\r\n\t\t\t\t\t\"Material\": {\r\n\t\t\t\t\t\t\"Name\": \"CarbonSteel\",\r\n\t\t\t\t\t\t\"AngleDependency\": \"Ductile\",\r\n\t\t\t\t\t\t\"Density\": 7800,\r\n\t\t\t\t\t\t\"K\": 0.000000002,\r\n\t\t\t\t\t\t\"N\": 2.6\r\n\t\t\t\t\t},\r\n\t\t\t\t\t\"Tag\": \"XMT Tee\",\r\n\t\t\t\t\t\"GeometryFactor\": 1,\r\n\t\t\t\t\t\"ErosionAllowance\": 3,\r\n\t\t\t\t\t\"PipeDiameter\": 0.1302\r\n\t\t\t\t}\r\n\t\t\t]\r\n\t\t}\r\n\t}\r\n}"
}
Responses
200 OK
Success
Representations
{
"geometryModel": "string",
"tag": "string",
"fluidVelocity": 0.0,
"erosionPerTon": 0.0,
"erosionPerYear": 0.0
}
{
"type": "object",
"properties": {
"geometryModel": {
"type": "string",
"nullable": true
},
"tag": {
"type": "string",
"nullable": true
},
"fluidVelocity": {
"type": "number",
"description": "Mixture velocity applied in erosion model",
"format": "double"
},
"erosionPerTon": {
"type": "number",
"description": "Erosion rate [mm/ton]",
"format": "double"
},
"erosionPerYear": {
"type": "number",
"description": "Erosion rate [mm/year]",
"format": "double"
}
},
"additionalProperties": false,
"description": "Calculation results for a single component."
}
400 Bad Request
Invalid or insufficient input. This includes valid input that is outside the model ranges.
Representations
{
"type": "string",
"title": "string",
"status": 0,
"detail": "string",
"instance": "string"
}
{
"type": "object",
"properties": {
"type": {
"type": "string",
"nullable": true
},
"title": {
"type": "string",
"nullable": true
},
"status": {
"type": "integer",
"format": "int32",
"nullable": true
},
"detail": {
"type": "string",
"nullable": true
},
"instance": {
"type": "string",
"nullable": true
}
},
"additionalProperties": {}
}
500 Internal Server Error
Calculation error. Unhandled exceptions.
Code samples
@ECHO OFF
curl -v -X POST "https://api.veracity.com/ext/dnvgl/rpo501/v2015/api/erosion/single/blackoilstream"
-H "Content-Type: application/json"
-H "Ocp-Apim-Subscription-Key: {subscription key}"
--data-ascii "{body}"
using System;
using System.Net.Http.Headers;
using System.Text;
using System.Net.Http;
using System.Web;
namespace CSHttpClientSample
{
static class Program
{
static void Main()
{
MakeRequest();
Console.WriteLine("Hit ENTER to exit...");
Console.ReadLine();
}
static async void MakeRequest()
{
var client = new HttpClient();
var queryString = HttpUtility.ParseQueryString(string.Empty);
// Request headers
client.DefaultRequestHeaders.Add("Ocp-Apim-Subscription-Key", "{subscription key}");
var uri = "https://api.veracity.com/ext/dnvgl/rpo501/v2015/api/erosion/single/blackoilstream?" + queryString;
HttpResponseMessage response;
// Request body
byte[] byteData = Encoding.UTF8.GetBytes("{body}");
using (var content = new ByteArrayContent(byteData))
{
content.Headers.ContentType = new MediaTypeHeaderValue("< your content type, i.e. application/json >");
response = await client.PostAsync(uri, content);
}
}
}
}
// // This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
import java.net.URI;
import org.apache.http.HttpEntity;
import org.apache.http.HttpResponse;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import org.apache.http.client.utils.URIBuilder;
import org.apache.http.impl.client.HttpClients;
import org.apache.http.util.EntityUtils;
public class JavaSample
{
public static void main(String[] args)
{
HttpClient httpclient = HttpClients.createDefault();
try
{
URIBuilder builder = new URIBuilder("https://api.veracity.com/ext/dnvgl/rpo501/v2015/api/erosion/single/blackoilstream");
URI uri = builder.build();
HttpPost request = new HttpPost(uri);
request.setHeader("Content-Type", "application/json");
request.setHeader("Ocp-Apim-Subscription-Key", "{subscription key}");
// Request body
StringEntity reqEntity = new StringEntity("{body}");
request.setEntity(reqEntity);
HttpResponse response = httpclient.execute(request);
HttpEntity entity = response.getEntity();
if (entity != null)
{
System.out.println(EntityUtils.toString(entity));
}
}
catch (Exception e)
{
System.out.println(e.getMessage());
}
}
}
<!DOCTYPE html>
<html>
<head>
<title>JSSample</title>
<script src="http://ajax.googleapis.com/ajax/libs/jquery/1.9.0/jquery.min.js"></script>
</head>
<body>
<script type="text/javascript">
$(function() {
var params = {
// Request parameters
};
$.ajax({
url: "https://api.veracity.com/ext/dnvgl/rpo501/v2015/api/erosion/single/blackoilstream?" + $.param(params),
beforeSend: function(xhrObj){
// Request headers
xhrObj.setRequestHeader("Content-Type","application/json");
xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key","{subscription key}");
},
type: "POST",
// Request body
data: "{body}",
})
.done(function(data) {
alert("success");
})
.fail(function() {
alert("error");
});
});
</script>
</body>
</html>
#import <Foundation/Foundation.h>
int main(int argc, const char * argv[])
{
NSAutoreleasePool * pool = [[NSAutoreleasePool alloc] init];
NSString* path = @"https://api.veracity.com/ext/dnvgl/rpo501/v2015/api/erosion/single/blackoilstream";
NSArray* array = @[
// Request parameters
@"entities=true",
];
NSString* string = [array componentsJoinedByString:@"&"];
path = [path stringByAppendingFormat:@"?%@", string];
NSLog(@"%@", path);
NSMutableURLRequest* _request = [NSMutableURLRequest requestWithURL:[NSURL URLWithString:path]];
[_request setHTTPMethod:@"POST"];
// Request headers
[_request setValue:@"application/json" forHTTPHeaderField:@"Content-Type"];
[_request setValue:@"{subscription key}" forHTTPHeaderField:@"Ocp-Apim-Subscription-Key"];
// Request body
[_request setHTTPBody:[@"{body}" dataUsingEncoding:NSUTF8StringEncoding]];
NSURLResponse *response = nil;
NSError *error = nil;
NSData* _connectionData = [NSURLConnection sendSynchronousRequest:_request returningResponse:&response error:&error];
if (nil != error)
{
NSLog(@"Error: %@", error);
}
else
{
NSError* error = nil;
NSMutableDictionary* json = nil;
NSString* dataString = [[NSString alloc] initWithData:_connectionData encoding:NSUTF8StringEncoding];
NSLog(@"%@", dataString);
if (nil != _connectionData)
{
json = [NSJSONSerialization JSONObjectWithData:_connectionData options:NSJSONReadingMutableContainers error:&error];
}
if (error || !json)
{
NSLog(@"Could not parse loaded json with error:%@", error);
}
NSLog(@"%@", json);
_connectionData = nil;
}
[pool drain];
return 0;
}
<?php
// This sample uses the Apache HTTP client from HTTP Components (http://hc.apache.org/httpcomponents-client-ga/)
require_once 'HTTP/Request2.php';
$request = new Http_Request2('https://api.veracity.com/ext/dnvgl/rpo501/v2015/api/erosion/single/blackoilstream');
$url = $request->getUrl();
$headers = array(
// Request headers
'Content-Type' => 'application/json',
'Ocp-Apim-Subscription-Key' => '{subscription key}',
);
$request->setHeader($headers);
$parameters = array(
// Request parameters
);
$url->setQueryVariables($parameters);
$request->setMethod(HTTP_Request2::METHOD_POST);
// Request body
$request->setBody("{body}");
try
{
$response = $request->send();
echo $response->getBody();
}
catch (HttpException $ex)
{
echo $ex;
}
?>
########### Python 2.7 #############
import httplib, urllib, base64
headers = {
# Request headers
'Content-Type': 'application/json',
'Ocp-Apim-Subscription-Key': '{subscription key}',
}
params = urllib.urlencode({
})
try:
conn = httplib.HTTPSConnection('api.veracity.com')
conn.request("POST", "/ext/dnvgl/rpo501/v2015/api/erosion/single/blackoilstream?%s" % params, "{body}", headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
########### Python 3.2 #############
import http.client, urllib.request, urllib.parse, urllib.error, base64
headers = {
# Request headers
'Content-Type': 'application/json',
'Ocp-Apim-Subscription-Key': '{subscription key}',
}
params = urllib.parse.urlencode({
})
try:
conn = http.client.HTTPSConnection('api.veracity.com')
conn.request("POST", "/ext/dnvgl/rpo501/v2015/api/erosion/single/blackoilstream?%s" % params, "{body}", headers)
response = conn.getresponse()
data = response.read()
print(data)
conn.close()
except Exception as e:
print("[Errno {0}] {1}".format(e.errno, e.strerror))
####################################
require 'net/http'
uri = URI('https://api.veracity.com/ext/dnvgl/rpo501/v2015/api/erosion/single/blackoilstream')
request = Net::HTTP::Post.new(uri.request_uri)
# Request headers
request['Content-Type'] = 'application/json'
# Request headers
request['Ocp-Apim-Subscription-Key'] = '{subscription key}'
# Request body
request.body = "{body}"
response = Net::HTTP.start(uri.host, uri.port, :use_ssl => uri.scheme == 'https') do |http|
http.request(request)
end
puts response.body